Here is where the problem is
System.out.println("First you saw, "+name1);
System.out.println("You then met , "+name2);
System.out.println("But, "+name3+" got in the way");
System.out.println("Though, "+name4+" helped you to recover your conversation");
System.out.println("Finally, "+ name3 +" apologized because "+name5 +" explained the situation");
Problem, is asking me to input a value into a variable when I want to print the preview input value
Here is the code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package newpackage;
import java.util.Scanner;
/**
*
* @author SOAD
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int i = 1;
Scanner input = new Scanner(System.in);
String name1,name2,name3,name4,name5;
while(i<5)
{
System.out.println("Please enter 5 names");
System.out.print("Name 1 :"); System.out.println(name1= input.nextLine());
System.out.print("Name 2 :"); System.out.println(name2=input.nextLine());
System.out.print("Name 3 :"); System.out.println(name3=input.nextLine());
System.out.print("Name 4 :"); System.out.println(name4=input.nextLine());
System.out.print("Name 5 :"); System.out.println(name5=input.nextLine());
i++;
}
System.out.println("First you saw, "+name1);
System.out.println("You then met , "+name2);
System.out.println("But, "+name3+" got in the way");
System.out.println("Though, "+name4+" helped you to recover your conversation");
System.out.println("Finally, "+ name3 +" apologized because "+name5 +" explained the situation");
}
}


Sign In
Create Account


Back to top









