David Ferguson
Hiya!
1 Answer(s)      5 years and 2 months ago
Posted in : Java Beginners

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!

Ads

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: