Concept explainers
Conversion
Write a program that asks the user to enter a distance in meters. The program will then present the following menu of selections:
- 1. Convert to kilometers
- 2. Convert to inches
- 3. Convert to feet
- 4. Quit the program
The program will convert the distance to kilometers, inches, or feet, depending on the user’s selection. Here are the specific requirements:
- • Write a void method named showKi1ometers, which accepts the number of meters as an argument. The method should display the argument converted to kilometers. Convert the meters to kilometers using the following formula:kilometers = meters * 0.001
- Write a void method named showlnches, which accepts the number of meters as an argument. The method should display the argument converted to inches. Convert the meters to inches using the following formula:inches = meters * 39.37
- Write a void method named showFeet, which accepts the number of meters as an argument. The method should display the argument converted to feet. Convert the meters to feet using the following formula:feet = meters * 3.281
- Write a void method named menu that displays the menu of selections. This method should not accept any arguments.
- The program should continue to display the menu until the user enters 4 to quit the program.
- The program should not accept negative numbers for the distance in meters.
- If the user selects an invalid choice from the menu, the program should display an error message.
Here is an example session with the program, using console input. The user’s input is shown in bold.
Enter a distance in meters: 500 [Enter]
- 1. Convert to kilometers
- 2. Convert to inches
- 3. Convert to feet
- 4. Quit the program
Enter your choice: 1 [Enter]
500 meters is 0.5 kilometers.
- 1. Convert to kilometers
- 2. Convert to inches
- 3. Convert to feet
- 4. Quit the program
Enter your choice: 3 [Enter]
500 meters is 1640.5 feet.
- 1. Convert to kilometers
- 2. Convert to inches
- 3. Convert to feet
- 4. Quit the program
Enter your choice: 4 [Enter]
Bye!
Learn your wayIncludes step-by-step video
Chapter 5 Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (4th Edition)
Mechanics of Materials (10th Edition)
Problem Solving with C++ (10th Edition)
SURVEY OF OPERATING SYSTEMS
Degarmo's Materials And Processes In Manufacturing
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
- Math 130 Introduction to Java programming May I please have a written review expressing my gratitude for a tutor that has given my guidance throughout my computer programming course? Thank youarrow_forwardPlease help me translate the java code to jack codearrow_forwardTranslate the following VM commands to Assembly instructions: □ push constant 1 □ push constant 5arrow_forward
- Suppose the state of the argument and local memory segments are as follows: argument local stack 0 0 9 sp-> 256 1 257 1 14 2 258 259 Now consider the following VM code: 1 push constant 2 pop local @ 3 push constant 15 4 pop local 1 5 push local 1 6 push argument 1 7 gt 8 pop local 2 9 push local 0 10 push argument 0 11 add 12 pop local 0 13 push local 1 14 push local 1 15 push constant 1 16 sub 17 add 18 pop local 1 What will be the value of local 1 after the VM code has executed?arrow_forwardSuppose the state of the RAM is as follows and the adjacent assembly code will execute: RAM 0 3 1 2 2 0 فيا 3 6 456 5 1 4 1234567 $1 A = M A = M A = M D = M @4 M = D What will be the value of the RAM[4] following the assembly code execution?arrow_forwardPlease help me answer this , the context is for the Nand2Tetris Hack Assembly VM Emulatorarrow_forward
- help filling this out pleasearrow_forwardWhat command do I give to compile this project and run App.javaarrow_forwardTwo industries that use decision trees extensively are lenders (banks, mortgage companies, etc.) and insurance. Discuss how a decision tree is used to solve a business problem.arrow_forward
- and some More lab 9 For the last lab of the term, I want you to create a practical application for your database, in which you modify it in some way, for instance, taking a new order. Since the emphasis is on the database connectivity, neither a GUI nor a web application is required. In fact, a GUI would require x2go, which I don't have at home and you probably don't either. A web interface would need to be on osiris, I could figure out some way to try it out, I guess. There are also numerous security concerns. The applications should be easy for someone like a store employee or on-line customer to use. The most common operations, such as adding a customer or renting a tool, should be implemented. These Part 1 instructions now include how to use postgresql in C as well as Java and python. The important issue of transactions and commit status is addressed here. Some previous notes about web applications, and the PHP language [Previously I wrote] Now write one more program, that updates…arrow_forwardc# app formarrow_forward(a) Giving C and k constants, determine the big-theta for the function: f(x) = 9x4 − x³ +5x+2+(-13 + 9x³ - 7x)log(8x6 + 5x³ + 9x² + 11x + 3) -arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT