Percentage calculator (java project)
Code:-
import java.util.Scanner;
public class percentcalculator{
public static void main (String []args){
Scanner x = new Scanner(System.in);
System.out.println ("Enter a number:");
Double a = x.nextDouble();
Scanner y = new Scanner(System.in);
System.out.println ("Enter percentage:");
Double b = y.nextDouble();
Double c = a*b;
Double d = c/100;
System.out.println (b + "% of " + a + " is: " + d);
}
}
Output:-
Run using https://www.jdoodle.com/online-java-compiler or any other decoder.
import java.util.Scanner;
public class percentcalculator{
public static void main (String []args){
Scanner x = new Scanner(System.in);
System.out.println ("Enter a number:");
Double a = x.nextDouble();
Scanner y = new Scanner(System.in);
System.out.println ("Enter percentage:");
Double b = y.nextDouble();
Double c = a*b;
Double d = c/100;
System.out.println (b + "% of " + a + " is: " + d);
}
}
Output:-
Run using https://www.jdoodle.com/online-java-compiler or any other decoder.
Comments
Post a Comment