Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following code does not show errors in NetBeans. It even compiles properly.

ID: 3844805 • Letter: T

Question

The following code does not show errors in NetBeans. It even compiles properly. However, the code crashes after entries have been made.

a. What is the issue?

b. How would you fix it?

c. After it is fixed (supply the fixed code), what would the formatted output be?

Note***The variables are declared correctly

//Begin Main Method

public static void main(String[] args) {

int age = 0;

String fName; Scanner sc = new Scanner(System.in);

System.out.print("Please enter your first name: ");

fName = sc.next();

System.out.print("Please enter your age: ");

age = sc.nextInt();

System.out.printf("Hello %d You don't look like you're %f years old! ", fName, age);

} //End Main Method Previous Next

Explanation / Answer

a. What is the issue?

->I think the issue is with u r print statement..

b. How would you fix it?

->you have to use cancatenation operator while printing the values of the variables..

c. After it is fixed (supply the fixed code), what would the formatted output be?

->System.out.print("Hello"+fname+" you don't look like you're"+age);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote