Please help me fix the error in this program 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ID: 3584572 • Letter: P
Question
Please help me fix the error in this program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import java.util.Scanner; public class Child1 { public static void main(String [] args){ float a,b,c,d; Scanner sc = new Scanner(System.in); System.out.println("Please Enter the value of 1st number"); a = sc.nextFloat(); System.out.println("Please Enter the value of 2nd number"); b = sc.nextFloat(); System.out.println("Please Enter the value of 3rd number"); c = sc.nextFloat(); System.out.println("Please Enter the value of 4th number"); d = sc.nextFloat(); System.out.println("The Sum of 4 numbers is :"+(a+b+c+d)); System.out.println("The product of 4 numbers is :"+(a*b*c*d)); System.out.println("The product of sum of 1st 2 numbers and last 2numbers is :"+((a+b)*(c+d))); } }
Main.java:2: error: class Child1 is public, should be declared in a file named Child1.java public class Child1 { ^ 1 error Main.java:2: error: class Child1 is public, should be declared in a file named Child1.java public class Child1 { ^ 1 error Please help me fix the error in this program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import java.util.Scanner; public class Child1 { public static void main(String [] args){ float a,b,c,d; Scanner sc = new Scanner(System.in); System.out.println("Please Enter the value of 1st number"); a = sc.nextFloat(); System.out.println("Please Enter the value of 2nd number"); b = sc.nextFloat(); System.out.println("Please Enter the value of 3rd number"); c = sc.nextFloat(); System.out.println("Please Enter the value of 4th number"); d = sc.nextFloat(); System.out.println("The Sum of 4 numbers is :"+(a+b+c+d)); System.out.println("The product of 4 numbers is :"+(a*b*c*d)); System.out.println("The product of sum of 1st 2 numbers and last 2numbers is :"+((a+b)*(c+d))); } }
Main.java:2: error: class Child1 is public, should be declared in a file named Child1.java public class Child1 { ^ 1 error Explanation / Answer
www.experts-exchange.com/Programming/Languages/Java visit here
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.