Check this code for this assignment: It runs successfully on Netbeans IDE but there is no output. // Create a Scanner object to read user input Scanner input = new Scanner(System.in); // Prompt the user to enter the street number System.out.print("Enter street number: "); int streetNumber = input.nextInt(); input.nextLine(); // Prompt the user to enter the street name System.out.print("Enter street name: "); String streetName = input.nextLine(); // Prompt the user to enter the number of rooms in the house System.out.print("Enter number of rooms: "); int numRooms = input.nextInt(); input.nextLine(); // Create an array to store the room types String[] roomTypes = { "living", "dining", "bedroom1", "bedroom2", "kitchen", "bathroom" }; // Create an array to store the area of each room int[] roomAreas = new int[6]; // Prompt the user to enter the area of each room for (int i = 0; i < 6; i++) { System.out.print("Enter area of " + roomTypes[i] + " room: "); roomAreas[i] = input.nextInt(); input.nextLine(); } // Prompt the user to enter the price per sq. ft. System.out.print("Enter price per sq. ft.: "); double pricePerSqFt = input.nextDouble(); // Calculate the total area of the house int totalArea = 0; for (int i = 0; i < 6; i++) { totalArea += roomAreas[i]; } // Calculate the estimated property value double estimatedValue = totalArea * pricePerSqFt; // Display the results System.out.println("\n1. Street: " + streetName + " #" + streetNumber); System.out.print("2. Total Rooms: " + numRooms + " ("); for (int i = 0; i < 6; i++) { System.out.print(roomTypes[i]); if (i < 5) { System.out.print(", "); } } System.out.println(")"); System.out.println("3. Total Area: " + totalArea + " sq. ft."); System.out.println("4. Price per sq. ft: $" + pricePerSqFt); System.out.println("5. Estimated property value: $" + estimatedValue); } }
Check this code for this assignment: It runs successfully on Netbeans IDE but there is no output.
// Create a Scanner object to read user input
Scanner input = new Scanner(System.in);
// Prompt the user to enter the street number
System.out.print("Enter street number: ");
int streetNumber = input.nextInt();
input.nextLine();
// Prompt the user to enter the street name
System.out.print("Enter street name: ");
String streetName = input.nextLine();
// Prompt the user to enter the number of rooms in the house
System.out.print("Enter number of rooms: ");
int numRooms = input.nextInt();
input.nextLine();
// Create an array to store the room types
String[] roomTypes = { "living", "dining", "bedroom1", "bedroom2", "kitchen", "bathroom" };
// Create an array to store the area of each room
int[] roomAreas = new int[6];
// Prompt the user to enter the area of each room
for (int i = 0; i < 6; i++) {
System.out.print("Enter area of " + roomTypes[i] + " room: ");
roomAreas[i] = input.nextInt();
input.nextLine();
}
// Prompt the user to enter the price per sq. ft.
System.out.print("Enter price per sq. ft.: ");
double pricePerSqFt = input.nextDouble();
// Calculate the total area of the house
int totalArea = 0;
for (int i = 0; i < 6; i++) {
totalArea += roomAreas[i];
}
// Calculate the estimated property value
double estimatedValue = totalArea * pricePerSqFt;
// Display the results
System.out.println("\n1. Street: " + streetName + " #" + streetNumber);
System.out.print("2. Total Rooms: " + numRooms + " (");
for (int i = 0; i < 6; i++) {
System.out.print(roomTypes[i]);
if (i < 5) {
System.out.print(", ");
}
}
System.out.println(")");
System.out.println("3. Total Area: " + totalArea + " sq. ft.");
System.out.println("4. Price per sq. ft: $" + pricePerSqFt);
System.out.println("5. Estimated property value: $" + estimatedValue);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images