I have an assignment that wants me to write an application that takes 5 numbers from a user. As the user inputs the numbers I have to make them into a double, float, long, int and byte. All I need after this is to output the result of the following calculation.
Subtract the floatValue from the intValue, then multiply by the doubleValue, then divide by the longValue, then multiply by the byteValue and then divide by 2. I am to store the result in an int variable. I can get the user input but am at a loss as to how to do the calculation and store the result. Can someone out in cyberworld help. Thanks to anyone who responds.
CODE
import java.util.*;
public class TestNumbers
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
int result;
System.out.println("Enter a number:");
double num1 = input.nextDouble();
System.out.println();
System.out.println("Enter second number:");
float num2 = input.nextFloat();
System.out.println();
System.out.println("Enter third number:");
long num3 = input.nextLong();
System.out.println();
System.out.println("Enter fourth number:");
int num4 = input.nextInt();
System.out.println();
System.out.println("Enter fifth number:");
byte num5 = input.nextByte();
System.out.println();
}
}