-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTraveling
36 lines (34 loc) · 1.18 KB
/
Traveling
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package NestedLoops.Lab;
import java.util.Scanner;
public class traveling {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean condition = true;
boolean condition1 = true;
String destination = "null", money = "null";
double neededMoney = 1, investedMoney = 0;
while (condition) {
destination = input.nextLine();
if (destination.equals("End")){
condition = false;
break;
} else {
money = input.nextLine();
neededMoney = Double.parseDouble(money);
while (neededMoney > investedMoney) {
money = input.nextLine();
if (money.equals("End")){
condition1 = false;
condition = false;
break;
}
investedMoney += Double.parseDouble(money);
}
if (neededMoney <= investedMoney) {
System.out.printf("Going to %s!%n", destination);
}
investedMoney = 0;
}
}
}
}