posts deleted by s.sariyan:
post 1:
i wrote the text file values at the top; first, second and third journey and parts of the formula is at the top too:
text file contains:
first
1
100 40
200 70
second
0
300 60
third
2
300 80
200 50
400 60
and format plus formulas:
<name>
<N> // N is the number of changes
<FB><DB> // for each leg B, FB is the distance and DB is the speed. Note B=(N+1)
post 2:
the data to work with are the distance, the speed and number of changes in journey, the formulas are
the distance devided by speed in which :
program needs to read data in textfile from the following format:
<name> // First, Second, Third
<N> // N is the number of changes
<FB><DB> // for each leg B, FB is the distance and DB is the speed. Note B=(N+1).
--- Update ---
sorry for my english language : (
post 3:
the text file contains:
first //Name
1 //Number of changes
100 40 //distans and 40 the speed
200 70 //distans and 70 the speed
second //Second journey
0 //number of change
300 60 // 300 distance and 60 speed
third //third journey
2 // number of change
300 80 // the distance and the speed
200 50 // the distance and the speed
400 60 // the distance and the speed
i dont know how to read the data from the text file in the following format:
<name>
<number of changes>
<distance> and <speed>
in terms of calculations, the program should calculate the time that takes for each journey then the program should compare the time with requested time from the user. if the calculated time matches the user input then the program should display the output.
post 4:
I have no problem with reading and writing the file line by line,, I am struggling with reading the file in this specific format. I dont know how to assign data in the text file to variables for later calculations.
The formula is: time = distance(number of change+1) devided by speed(number of changes +1) i am also not sure about the formula. how to compare the result of calculation with user input!
the steps:
1.Request time period from the user
2.read the text file in following format(mentioned above)
3.calculate the time that takes for each journey in the text file
4.compare the result with user input
5.display the output based on the comparison(if the journeys are appropriate or not)
6.if the journey is appropriate and matches the user input, save it to a different text file
I hope i was able to explain it and make it more understandable : ) Thank you
post 5:
user= JOptionPane.showInputDialog ( "Request Time:" );
Scanner inFile = new Scanner(new FileReader ("data.txt"));
String user;
String name;
int change;
int distance;
int speed;
int sum;
int ch = Integer.parseInt(args[0]);
int di = Integer.parseInt(args[1]);
int sp = Integer.parseInt(args[2]);
JOptionPane.showMessageDialog(null, "journey name: "+name+" \n Number of Changes: "+ch+" \n Distance and speed: "+di, "Journey Planner",JOptionPane.INFORMATION_MESSAGE);
}
}
i think that I have done this completely wrong, as i mentioned i am a complete beginner sorry : )