The Java code must have the structure as shoen in the picture:
Develop with Java programming language a calculator (console application) that takes a number, a basic math operator ( + , - , * , / , % ), and a second number all from user input, and have it print the result of the mathematical operation. The mathematical operations should be wrapped inside of functions.
Note: Do please use the provided source code template to implement your solution. The purpose of this problem is not only to assess the students' ability to build a valid implementation but also to assess the ability to read the Java code.
Input:
On single line a number, a basic math operator ( + , - , * , / , % ), and a second number all from user input.
Output:
On new line result of the mathematical operation. In the case of "Division by zero" you must printout the text message "Error".
Example 1:
4 + 8
12
Example 2:
4 * 8
32
Example 3:
4 % 2
0
Example 4
4/0
Error
Example 5:
4-10
-6
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Values, not references, are accepted in Java's method arguments. What does this imply, specifically?arrow_forwardIn java: Develop a void function that takes two parameters, an integer and a string. The function should print the string as many times as given by the integer. For example, with arguments 4 and “Hello” the function would print “Hello” four times. Call the function twice with different arguments. What happens when the argument is negative?arrow_forwardWrite a C# program named Averages that includes a method named Average that accepts any number of numeric parameters, displays them, and displays their average. For example, if 7 and 4 were passed to the method, the output would be: 7 4 -- Average is 5.5 Test your function in your Main(). Tests will be run against Average() to determine that it works correctly when passed one, two, or three numbers, or an array of numbers.arrow_forward
- Please design a problem to show the three types of data conversions. For example, if you run the program, it may display the following messages: Problems @ Javadoc Declaration Console X Data Hierarchy Conversion [Java Application] C:\Program Files\Eclipse Foundation\b 1. This is to show assignment conversion: Enter an int for a: 3 Converted an int to a double by assignment. int a is 3 double b is 3.0 2. This is to show promotion coversion: Enter an int for c: 5 Enter a double for d: 2.0 Assign c/d to e. int cis 5 double d is 2.0 output e is 2.5 3. This is to show casting conversion: Enter a double for f: 5.7 Enter an int for g: 2 Assign f/g to h. double f is 5.7 int g is 2 output h is 2 When you run our program, the numbers must be typed from input but not be assigned in your program. You can type the same numbers as in the example or you may type other numbers, but please display all the three data conversions.arrow_forwardJavaarrow_forwardImplement a C++ program:RESTAURANT that has multiple branches, and each branch has menus of food items, their stock and a list of customers. A branch may have for example a breakfast menu and lunch menu with different food items, and the stock (available quantity) of each food item in the branch. Also, the branch will have a list of regular customers and their contact information to contact them for offers and new food items. Class Names Data and Member Functions Food Data Members: ID, Name, Calories, Price Member Functions: getID, getName, getCalories, getPrice setID, setName, setCalories, setPrice Stock Data Members: ID, Food, Stock Member Functions: getID, getFood, getStock setID, setFood, setStock Customer Data Members: ID, Name, Phone Member Functions: getID, getName, getPhone setID, setName, setPhoe Menu Data Members: ID, Name, foodList Member Functions: getID, getName, getFoodList setID, setName Branch Data Members: ID, Address, menuList, stockList, customerList Member…arrow_forward
- In Java Given the following function: static int Fun(int x,String w, double y) {x=3; return x;} What is the name of the function? What is the type of the function? What is the definition of the formal parameters? What are the function “fun”?arrow_forwardI am having so much difficulty coding this program. It would mean so much if I could have a screenshot of the full working code from Java. Thank you so much and take care!arrow_forwardWrite a Better version for this code using any preferred programming language. You should follow the high-quality code concepts and practices to achieve the high-quality version.arrow_forward
- Please refer to the pic and answer the questionsarrow_forwardWriting a Modular Program in Java Summary In this lab, you add the input and output statements to a partially completed Java program. When completed, the user should be able to enter a year, a month, and a day to determine if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31. Instructions Notice that variables have been declared for you. Write the simulated housekeeping() method that contains input statements to retrieve a year, a month, and a day from the user. Add statements to the simulated housekeeping()method that convert the String representation of the year, month, and day to ints. Include the output statements in the simulated endOfJob()method. The format of the output is as follows:month/day/year is a valid date. or month/day/year is an invalid date. Execute the program entering the following date: month = 5, day = 32, year =2014Observe the output of this…arrow_forwardUse Java. Please see the requirements (good indentation, matching the code EXACTLY how it is below, etc.)arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education