Please help me fix this program, when I run it, I keep getting errors. Please Po
ID: 3584569 • Letter: P
Question
Please help me fix this program, when I run it, I keep getting errors. Please Post Fixed program.
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)));
}
}
Explanation / Answer
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));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.