2 3 4 class MyLab{ java.util.Scanner; 5 public static void main(string []args) 6 { 7 System.out.println("Hello"); 8 System.out.println(" My name is noor"); 9//Scanner class object to read input from user 10 Scanner sc = new scanner(System.in); 11//Reading inputs from user 12 System.out.print("enter water amount:"); 13 float M sc.nextFloat(); 14 System.out.print("enter initial temperature:"); 15 float init_temp = sc.nextFloat(); 16 System.out.print("enter final temperature:"); 17 float final_temp = sc.nextFloat(); 18//calculate energy needed 19 double Q= M* (final_temp init_temp) * 4184; 20 System.out.println("The energy needed is "+Q+" joules"); 21//closing scanner class object 22 sc.close(); 23} 24 } 4 MyLab.java Compile Messages JGRASP Messages Run I/O Interactions Stop MyLab.java:3: error: <identifier> expected import package java.util.scanner; ^ Clear 1 error Copy
Added by David M.
Close
Step 1
The code starts by printing "Hello" and "My name is noor" on separate lines. Show more…
Show all steps
Your feedback will help us improve your experience
John Bell and 101 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
(Science: calculating energy) Write a program that calculates the energy needed to heat water from an initial temperature to a final temperature. Your program should prompt the user to enter the amount of water in kilograms and the initial and final temperatures of the water. The formula to compute the energy is $Q=M *(f \text { inalTemperature }-\text { initialTemperature }) * 4184$ where $M$ is the weight of water in kilograms, temperatures are in degrees Celsius, and energy $Q$ is measured in joules. Here is a sample run:
(Science: calculate energy) Write a program that calculates the energy needed to heat water from an initial temperature to a final temperature. Your program should prompt the user to enter the amount of water in kilograms and the initial and final temperatures of the water. The formula to compute the energy is $Q=M *(\text { finalTemperature }-\text { initialTemperature }) * 4184$ where $M$ is the weight of water in kilograms, temperatures are in degrees Celsius, and energy $Q$ is measured in joules. Here is a sample run: Enter the amount of water in kilograms: 55.5 Enter the initial temperature: 3.5 Enter the final temperature: 10.5 The energy needed is 1625484.0
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD