Write a program that accept three numbers,
multiply the first and the third numbers
and divide the results by the second number.
The output for the program should be as follows:
The first number is
The second number is
The third number is
Result is
import java.util.Scanner;
public class Calculate {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
System.out.print("Enter first number: ");
int first=scan.nextInt();
System.out.print("Enter second number: ");
int second=scan.nextInt();
System.out.print("Enter third number: ");
int third=scan.nextInt();
double calculating=(double)(first*third)/second;
System.out.println("The first number is: "+first);
System.out.println("The second number is: "+second);
System.out.println("The third number is: "+third);
System.out.printf("The result is: %.2f",calculating);
}
}
Comments
Leave a comment