Categories: Uncategorized

Java Programming Assignment | Get Paper Help

Lab Assignment 6
Methods
Due Date: 07 / 05
Your name and Lab assignment number must be included at the top of the Java source file in comments.
Name your file and class name: LabAssign6_YourLastName
NOTE: YOU MUST USE METHODS IN THIS ASSIGNMENT. An Assignment with no use of methods will receive a 0 grade
On successful completion of this assignment you will demonstrate the use and understanding of:
• Method use, implementation, calls and types
• The scanner class, control structures, catching invalid input (looping), logical & analytical thinking
Instructions
• Write a program that simulates a simple calculator.
This calculator is limited to the following functions:
➢ Addition
➢ Subtraction
➢ Multiplication
➢ Division
• Your program requires a total of 6 methods (INCLUDING THE MAIN)
These methods are listed and explained below:
o The main method which will perform the following actions:
➢ Declare necessary variables (number1, number2, choice, answer)
➢ Welcome the user
➢ Prompt for the first number (double)
➢ Prompt for the second number (double)
➢ Prompt for the arithmetic choice (int)
➢ Validate the choice prompt using a do while loop (1-4 are VALID entries)
➢ Create ONE control structure to determine which method to call based on users input to choice variable
➢ Call displayResults method passing the answer variable to display the answer.
o Four methods of type double which take as arguments the users two doubles and returns the appropriate calculation. Hint these methods will all be very similar, apart from the math.
➢ public static double calcSum(double d1, double d2)
➢ public static double calcSub(double d1, double d2)
➢ public static double calcMul(double d1, double d2)
➢ public static double calcDiv(double d1, double d2)
o One method of type void which will take as an argument the double variable from the main methods which pertains to the users answer (a method call itself)
➢ public static void displayResults(double ans)
CIT111
Your program should compile with no errors & make use of methods to earn full points.
Hint: The 4 methods calcSum, calcSub, calcMul, calcDiv are essentially the same method with very minor changes needed!
If you need help, ask! ValidationValidation Loop!Loop!

Don't use plagiarized sources. Get Your Custom Essay on
Java Programming Assignment | Get Paper Help
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay
Suzie Mercy

Recent Posts

What is the easy difination of science | Quick Solution

Science is the pursuit and application of knowledge and understanding of the natural and social…

4 years ago

definition, values, meaning of such values and type of goods with such elasticity value …….. | Quick Solution

Clearly stating the definition, the values, the meaning of such values and the type of…

4 years ago

Acct 422 – Nora D | Quick Solution

All answered must be typed using Times New Roman (size 12, double-spaced) font. No pictures…

4 years ago

Acct 322 – Nora D | Quick Solution

All answered must be typed using Times New Roman (size 12, double-spaced) font. No pictures…

4 years ago

Macro Economics Question | Quick Solution

https://www.npr.org/sections/ed/2018/04/25/605092520/high-paying-trade-jobs-sit-empty-while-high-school-grads-line-up-for-university Click on the link above. Read the entire link and answer the questions below…

4 years ago

MGT 322 – Nora D | Quick Solution

All answered must be typed using Times New Roman (size 12, double-spaced) font. No pictures…

4 years ago