How can I write two words as a variable in the input String Scanner method? jetbrains academy challenge
package com.Scanner;
import java.util.Scanner;
public class Scaner {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine(); //Nick
int age = scanner.nextInt();// 25
scanner.nextLine();
String education = scanner.nextLine(); //secondary
int experience = scanner.nextInt(); //3
scanner.nextLine();
String fusion dishes = scanner.nextLine();// не компилирует
System.out.println("The form for Nick is completed. We will contact you if we need a chef that cooks fusion dishes");
Input мне нужно ввести 5 параметра
name,
age,
education,
experience,
fusion dishes.
Output The form for Nick is completed. We will contact you if we need a chef that cooks fusion dishes.
0
Author: Nick Petrych, 2020-05-23
2 answers
I don't know why, but you can do it like this:
String fusion, dishes;
fusion = dishes = scanner.nextLine();
0
Author: Олексій Моренець, 2020-05-23 10:23:36
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine(); //Nick
int age = scanner.nextInt();// 25
scanner.nextLine();
String education = scanner.nextLine(); //secondary
int experience = scanner.nextInt(); //3
scanner.nextLine();
String fusion = scanner.nextLine();
String fusionDishes = scanner.nextLine();
System.out.println("The form for " + name + " is completed. We will contact you if we need a chef that cooks " + fusionDishes);
}
I recommend reading the basics of java. These are very simple tasks, so you will not go far further.
0
Author: AlekseiGaile, 2020-05-23 16:28:18