Für die folgenden habe ich eine schwierige Zeit zu verstehen, wie meine Benutzereingabe von (Tage) zu verwenden und es in der letzten Zeile verwenden, um die Anzahl der Stunden und Minuten basierend auf zu berechnen die Benutzereingabe von (Tage).Wie Benutzereingaben später in einer anderen Methode verwenden
import java.util.Scanner;
public class LearnScanner {
public static void main (String[] args) {
first();
next();
third();
}
public static void first() {
Scanner input = new Scanner(System.in);
System.out.println("Welcome to Vacation Planner!!");
System.out.print("What is your name?");
String name = input.nextLine();
System.out.print("Nice to meet you "+name +", where are you travelling to?");
String destination = input.nextLine();
System.out.print("Great! "+destination +" sounds like a great trip");
}
public static void next() {
Scanner input = new Scanner(System.in);
System.out.print("How many days are you going to spend travelling?");
String days = input.nextLine();
System.out.print("How much money in USD are you planning to spend on your trip?");
String budget = input.nextLine();
System.out.print("What is the three letter currency symbol for your travel destination?");
String currency = input.nextLine();
System.out.print("How many " + currency + " are there in 1 USD?");
String currencyConversion = input.nextLine();
}
public static void third() {
String days;
String hours = days * 24;
String minutes = hours * 60;
System.out.println("If your are travelling for " + days + " days that is the same as " + hours + " hours or " + minutes + " minutes");
}
}
Was passiert, wenn Sie es so machen, wie Sie es gerade tun? Wenn Sie einen Fehler erhalten, teilen Sie bitte die Fehlermeldung mit. – Antimony
Fehler (36,28) Java: '.class' erwartet Fehler (36,33) Java: keine Anweisung * Zeile 36 ist: String Stunden = Tage * 24; –