+ 1

What is the problem in this code? i really don't understand.

import java.util.Scanner ; public class PercentageCal{ public static void percent1(float a,float b){ result =a/b*100; } } public class Mainclass{ public static void main(String []args){ float x=0; float y=0; System .out.println ("enterr x and y"); Scanner scanner = new Scanner(System.in); x= scanner.nextFloat(); y= scanner.nextFloat(); float result =percent1(x,y); System .out.println ("percentage is:"+result); } }

29th Mar 2018, 5:32 AM
Pooja chouhan
Pooja chouhan - avatar
1 Answer
+ 1
import java.util.Scanner ; public class PercentageCal{ public static float percent1(float a,float b){ float result =a/b*100; System.out.println ("percentage is:"+result); return result; } } public class Mainclass{ public static void main(String []args){ float x=0.0f; float y=0.0f; System.out.println ("enterr x and y"); Scanner scanner = new Scanner(System.in); x= scanner.nextFloat(); y= scanner.nextFloat(); PercentageCal pc=new PercentageCal (); float result =pc.percent1(x,y); } } thank you now the code is running
29th Mar 2018, 1:02 PM
Pooja chouhan
Pooja chouhan - avatar