Connect with a global community of experts on IDNLearn.com. Ask your questions and receive accurate, in-depth answers from our knowledgeable community members.
1) Assignment: Write a full program with class name Calculator to solve a calculator problem that prompts the user for 2 (double) numbers and an operator (char) and outputs the result.
2) Assignment: In a new eco-friendly transportation system, vehicles are categorized by their emission levels to encourage lower emissions. The categories are as follows:
0: Electric
1: Hybrid
2-4: Gasoline Low Emission
5: Gasoline
6-9: Diesel
Given an int variable vehicleType, write a switch statement that prints out the emission category based on vehicleType. For example, if vehicleType is 2, print "Gasoline Low Emission".
3) Assignment: Write an expression using the conditional operator ? : that evaluates the variable age and prints the message "You are eligible to vote." if age is greater or equal to 18 or prints "You are not eligible to vote." otherwise.
4) Assignment: Write a statement that evaluates the int variable ages and prints the following, using the ternary operator:
"Child": 0-12 years
"Teen": 13-19 years
"Adult": 20-64 years
"Senior": 65 years and above
5) Assignment: In a new loyalty program for a café, customers are classified into tiers based on the number of coffee cups they've purchased. Each tier rewards customers with different benefits.
Write an expression that evaluates the int variable coffeeCups, and prints one of the following, using the ternary operator:
"None"
"Bronze"
"Silver"
"Gold"
"Platinum"
The following values of coffeeCups define the categories:
None: if the number of coffees is less than 10.
Bronze tier is awarded between 10 cups and 19.
Silver tier is awarded between 20 cups and 29,
Gold tier is awarded between 30 and 39,
Platinum tier is awarded over 39 cups.
write each one into a java code.
class name: Exercise
Sagot :
Your participation is crucial to us. Keep sharing your knowledge and experiences. Let's create a learning environment that is both enjoyable and beneficial. IDNLearn.com is committed to your satisfaction. Thank you for visiting, and see you next time for more helpful answers.