Hiya!

Hiya!

Write a program to input an integer and output whether or not it is a valid percentage

if anyone could help that would be great

Thanks in advance!

View Answers

October 25, 2011 at 3:33 PM

import java.util.*;
class CheckPercentage 
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter percent: ");
        double percent=input.nextDouble();
        if((percent>0)&&(percent<=100)){
            System.out.println("Valid Percentage.");
        }
        else{
            System.out.println("Not Valid!");
        }
    }
}









Related Tutorials/Questions & Answers:

Ads