i am currently doing a small task in java which i am very new to so please excuse any silly mistakes i have made. Basically i am trying to take 2 values from a text document, import them into my java document and then multiply them together. These 2 numbers are meant to represent the hourly pay and amount of hours worked, then the output is the total amount the member of staff has earned. This what i have so far ...
import java.util.*;
import java.io.*;
public class WorkProject
{
Scanner inFile = new Scanner(new FileReader("staffnumbers.txt"));
double Hours;
double Pay;
Hours = inFile.nextDouble();
Pay = inFile.nextDouble();
double earned = Length * Width;
System.out.println(earned);
}
What i have so far is basically me trying to get the .txt document into my java file. I'm not sure if this is right and then i'm not sure where to go to get the values to multiply and have it outputted. I understand what i have so far is probably just the very start of what i need but any help will be massively appreciated as i am keen to learn. Thanks so much .... Hannah
I'm not sure if this is rightwell, you can check, simply writeSystem.out.println(earned)to see if you've done it right.Amountand set it equal toHours * Pay.amountEarned. Best of luck to you learning how to program. ;)