Answer:
// program in java.
// package
import java.util.*;
// class definition
class Main
{
// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// object to read input
Scanner scr=new Scanner(System.in);
// ask to enter the name
System.out.print("Enter a name:");
// read name
String name=scr.nextLine();
// print the hello message
System.out.println("Hello "+name);
}catch(Exception ex){
return;}
}
}
Explanation:
Create a Scanner object to read name from user.Read name from user and assign it to variable "y_name".Then print the message Hello followed by the name.
Output:
Enter your name:Krish
Hello Krish
Answer:
D. a studio monitor
Explanation:
A studio monitor is an electrical equipment that is used to enhance the quality of sound or music. It work like a speaker that can be used professionals to record audio songs, to make films and some other applications with good quality. It is usually used in studios where producer must ensures that the quality of music. As in music industry the quality of music depends on the quality of instrument used for the purpose of recording.
<em>This is the reason that, Jimmy and his friends should choose a Studio Monitor to achieve the most accurate sound quality.</em>
Answer:
import java.util.Scanner;
public class CalculatingSales {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int product, quantity;
double total = 0;
while(true) {
System.out.println("Enter product_id and quantity(0 0 to stop): ");
product = sc.nextInt();
quantity = sc.nextInt();
if(product==0 && quantity == 0)
break;
switch (product) {
case 1:
total = total + 2.98*quantity;
break;
case 2:
total = total + 4.50*quantity;
break;
case 3:
total = total + 9.98*quantity;
break;
case 4:
total = total + 4.49*quantity;
break;
case 5:
total = total + 6.87*quantity;
break;
default:
System.out.println("Invalid option");
}
}
System.out.println("total value: "+total);
sc.close();
}
}
Explanation:
- Take the product and quantity as input from user.
- Use a switch statement to multiply the total with their relevant value.
- Display the total value.