Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can I see this program written in java? 1 gou. Vyr. keep new programmers from misusing System.exit We DO NOT USE System.exit AT ALL. ALSO:

can I see this program written in java?
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1 gou. Vyr. keep new programmers from misusing System.exit We DO NOT USE System.exit AT ALL. ALSO: Use ONLY ONE return statement per method. We DO NOT USE JOptionPane AT ALL because it slows down a program's input/output. Selection Assignment This assignment is designed to give you experience in creating a Java application with sequence and selection statements. When writing this programs, only use sequence and selection statements. Do not use loops, other statements or any data types that have not been covered so far. If in doubt, contact your instructor. REMEMBER: Programs that do NOT compile eam no more than 10% of their assigned point value. As you implement your solution consider which selection structure is best for your solution: an if-statement, an if-else statement or a switch statement. Each has its advantages in certain situations. Sometimes one is correct while another would be incorrect in certain situations Anytime the requirements dictate more than one input, always get the input from the user in the order given in the requirements. Every program written this semester MUST follow ALL the coding conventions for the course If you have any questions on this assignment, - coding or requirements -- send me Canvas email Requirements for the Java application, MiniCalculator.java Write a Java application named, MiniCalculator.java, that calculates the result of L 01 PM evaluating an arithmetic expression containing three operands (type, double) and two operators. This program should begin by printing a welcome message with the title of the application (program) and a brief description of what it does. (Note: this is NOT the same as the program prologue (https://earn.maricopa.edulcourses/1172388/pages/program-prologs reguld. The prologue is a set of comments at the beginning of your source code meant for other Java programmers.) This message and description displayed by the program are meant for the user of the program. Your message and description should be identical to the first five lines printed in every example execution of this program (see execution examples below) Next, the program must prompt the user for the expression. As you can see from the execution examples below, the program prompts for and reads each part of the expression before going to the next one. Therefore, there are five prompts and inputs, each on its own line (see examples below). The inputs must be promoted for and read in this order: 1. First operand 2. First operator (must be ../.or%) 3. Second operand 4. Second operator (*. - ./%) 5. Third operand This order is used in every execution example below. Use this order and word your prompts exactly as found in the example executions below. The user's input should be entered on the same line at the end of the prompt text. This is done is every example below. You should be prepared to use if-else and switch statements, as well as read user input using the Scanner's next and nextDouble methods. Do not use the Scanner's nextLine method. You may also find it helpful to use boolean flags. Input Validation As you can see from looking at the last two execution examples, your program should print an error message if the first operator is invalid, i.e., anything other than multiplication), (division), % (remainder). This error message would be displayed after reading the second operand. After printing this error message, the application should terminate: this means that control should logically reach the end of the main method. Do NOT use a return or a System.exit to force the termination of the program. The other error that your program will check for is whether the second operator is valid. TIAL The second operator can be + (addition), - (subtraction). (multiplication), / (division), or % (remainder). If the second operator is anything else, an error message as in the last execution example is displayed. After this, the application should terminate: this means that control should logically reach the end of the main method. Do NOT use a return or a System.exit to force the termination of the program. Note: that checking for these errors and then skipping normal processing to reach the end of main is all done by structuring the i-else statements correctly. This makes our code easier to read/understand/debug and eliminates to need for extra returns and other poor programming practices. Ask questions if you have trouble with this concept. Execution/Testing Your program should produce the exact same results shown in the execution examples (if the inputs are the same). However, you should also test your program by entering other expression NOT used in the examples below. Your program should ALWAYS produce the correct result for any entered expression that meets the stipulations of these requirements. The resulting value must always be formatted to three decimal places (use printf or String.format). NOTE: This program should ASSUME that all of the numeric operands entered are entered by the user without error. The program should not include input validation on the three operands. The following execution examples show what your program should look like as it executes. Your program should format the resulting values EXACTLY as the shown in the examples by using printf or String format. The wording of the introductory message, the prompts and all labels must be exactly as shown in these examples. The two operator errors must be handled exactly as indicated in the examples. If you have questions about the formatting, wording, etc., email your instructor RATHER THAN make an incorrect assumption Note: The user's inputs are shown in highlighted bold characters. This is only done to help you understand the examples. Your program does NOT display anything in bold or highlighted First example execution: Welcome to Mini Calculator I will calculate the value of expressions having three operands and two operators. The first operator must be either *, /, or . The second operator can be +, -, *, I. or t. Enter first operand: 8 Enter first operator (3,7,9): * Enter second operand: Enter second operator: Z Enter third operand: 6 RESULT: 8.0 * 3.8 / 6.0 = 4.000 Second example execution: Welcome to Mini Calculator I will calculate the value of expressions having three operands and two operators. The first operator must be either *, I. or. The second operator can be +. -. *. l. or. Enter first operand: 3 Enter first operator (*,/,): Enter second operand: 7 Enter second operator: Enter third operand: 6 RESULT: 3.8 7.0 - 6.0 = 15.000 Third example execution: Welcome to Mini Calculator I will calculate the value of expressions having three operands and two operators. The first operator must be either , /, or .. The second operator can be +, -, *, /, or 1. Enter first operand: 12.5 Enter first operator (*,/,4): / Enter second operand: 4.25 Enter second operator: - Enter third operand: 5 RESULT: 12.5 / 4.25 +5.0 = 7.941 Fourth example execution: Welcome to Mini Calculator I will calculate the value of expressions having three operands and two operators. The first operator must be either , /, or . The second operator can be +, -, *, /, or . Enter first operand: 4 enter tirst operator ,/, Enter second operand: 3 Enter second operator: - Enter third operand: 2 RESULT: 4.0 $ 3.0 - 2.0 = -1.080 Fifth example execution (shows an input error): Welcome to Mini Calculator I will calculate the value of expressions having three operands and two operators. The first operator must be either , /, or *. The second operator can be +, -, *, 1, or $. Enter first operand: 5 Enter first operator (*,7,9): - Enter second operand: 6 Error: First operator is invalid. Sixth example execution (shows an input error): Welcome to Mini Calculator I will calculate the value of expressions having three operands and two operators. The first operator must be either , /, or 4. The second operator can be *, /, or. Enter first operand: 6 Enter first operator (*./.*): Enter second operand: 4 Enter second operator: T Enter third operand: 7 Error: Second operator is invalid

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago