Reference no: EM13768576
Assignment 5
Goal
In this assignment you will program a menu-based calculator and practice using...
• Switch statements
• Loops
Requirements
Your program will perform one of two options repeatedly until the user quits your program.
• Create your program using Eclipse. Name your project Assignment5 and the Java class Loops.
• Use the Scanner class to get input from the user and use System.out to print to the console window.
• Use a while (or a do...while) to have the program loop until the user enter -1
• Inside the while, display a menu similar to the one below and use switch statement to respond to the user's choice
Please enter one of the following choices:
1 --> Largest Number
2 --> Factorial
-1 --> Quit
• For the Largest Number:
o Use ANOTHER while (or a do...while) loop ask the user to input an integer greater than or equal to 0 or -1 to quit.
Input an integer greater than or equal to 0 or -1 to quit:
o When the user enters -1, print out the largest number found
• For the Factorial:
o Ask the user for an integer that we will calculate the factorial.
o In math the factorial is notated as "n!". It is the product of all positive integers less than or equal to n. For example, 5! =5x4x3x2x1= 120. Meanwhile 3! = 3 x 2 x 1 = 6
o Here are the factorial rules
• If the integer is negative, display an error message
• Else if the integer is 0, then 0! = 1 so automatically print 1 as the answer
• Else calculate the factorial with a for loop and display the result.
o When finished, display the result
o Hint: use the factorial result as a long and not an int as the values can get quite large
• Display the result in a readable format.
• Be sure to comment your code.
Largest supplier of home goods in the northeast
: You are a new procurement manager with the largest supplier of home goods in the Northeast. The owner of the corporation is considering discontinuing the contract for the shipping of goods. He wants the corporation to invest in its own fleet of tr..
|
Different staffing levels
: Analyze the primary way in which different staffing levels may play pivotal roles in upholding ethical conduct, including treating patients with dignity.
|
What degree you believe harley-davidson is proceeding
: Discuss to what degree you believe Harley-Davidson is currently proceeding towards its mission, vision, and values - Identify two or three of H-D's most important stakeholders and discuss whether Harley-Davidson's current strategic direction is alig..
|
Analysis of an environmental disaster
: Recent environmental disasters have significantly impacted the human population in multiple ways. In this assignment, you will identify a recent environmental disaster and discuss potential correlated health impacts.
|
Create your program using eclipse
: Create your program using Eclipse. Name your project Assignment5 and the Java class Loops. Use the Scanner class to get input from the user and use System.out to print to the console window.
|
What is the companys approach to sustainability
: What is the company's approach to outsourcing and/or offshoring? What is the company's approach to sustainability?
|
Resources to use in researching a bankruptcy issue
: What is the standard for a consumer debtor to obtain discharge of a student loan on the grounds of "undue hardship"? Describe the resources to use in researching a bankruptcy issue
|
Aggregate demand curve is negatively sloped
: Aggregate demand curve is negatively sloped in part because of the impact of interest rates and the economy is in short-run equilibrium.
|
Issues in the automotive technology department
: After introducing yourself to the secretary you share with a half dozen other, more senior, people, you decide to focus on hazardous material and hazardous waste issues since you just completed a great college course on those topics. You tour the ..
|