TOPIC

5% Wrong answer in JAVA. Why?!!

hasanemo654 asked 7 months ago

import java.util.Scanner; public class Main{ public static void main(String [] args){ Scanner sc = new Scanner (System.in);

float a = sc.nextFloat();
float b = sc.nextFloat();
double c = sc.nextDouble();
double d = sc.nextDouble();

System.out.printf("A = %f, B = %f\nC = %f, D = %f\n",a,b,c,d);

System.out.printf("A = %.1f, B = %.1f\nC = %.1f, D = %.1f\n",a,b,c,d);

System.out.printf("A = %.2f, B = %.2f\nC = %.2f, D = %.2f\n",a,b,c,d); 

System.out.printf("A = %.3f, B = %.3f\nC = %.3f, D = %.3f\n",a,b,c,d);

System.out.printf("A = %.3E, B = %.3E\nC = %.3E, D = %.3E\n",a,b,c,d);

System.out.printf("A = %.0f, B = %.0f\nC = %.0f, D = %.0f\n",a,b,c,d);

}

}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.