+ 2

Whats wrong with the Code?

import java.util.Scanner; public class Main { public static void main(String[ ] args) { Scanner read = new Scanner(System.in); String firstName = read.nextLine(); String secondName = read.nextLine(); int age = read.nextInt(); int roomNumber = read.nextInt(); Customer customer = new Customer(); //set customer's data to object here costomer.firstName=firstName; costomer.secondName=secondName; costomer.age=age; costomer.roomNumber=roomNumber; customer.saveCustomerInfo(); } } public class Customer { //add all necessary attributes here String firstName; String secondName; int age; int roomNumber; public void saveCustomerInfo() { System.out.println("First name: " + firstName); System.out.println("Second name: " + secondName); System.out.println("Age: " + age); System.out.println("Room number: " + roomNumber); } }

27th Feb 2023, 5:16 PM
Tomato
Tomato - avatar
2 Réponses
+ 7
You have to decide which name you use costomer or customer.
27th Feb 2023, 6:03 PM
JaScript
JaScript - avatar
0
Just typos You defined variable name as "customer" but try to assign it's data on "costomer"
1st Mar 2023, 7:39 AM
Ayush kumar
Ayush kumar - avatar