Grades: Grade 1 Grade 2 Average Difference ======================================================== 85 92 88.5 7
Added by Josep W.
Close
Step 1
Choose an object: Let's implement a `CarV3` object. Show more…
Show all steps
Your feedback will help us improve your experience
Samuel Goyette and 99 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Expected Output: The following screenshot is an example of output for a StudentV3 object. The class contains two methods to calculate the average of two grades and the difference between the grades. Your output will differ based on the object you define.
Akash M.
The editing window below includes a custom class called "Calculator". For this assignment, you will develop the Calculator class to calculate values in custom methods, using data received from the Main() method (which you also must develop). In Main(), declare three integer variables: firstNum, secondNum, and output. Prompt the user with the text "Enter the first value:" and store that value in firstNum. Prompt the user with the text "Enter the second value:" and store that value in secondNum. Declare an instance of the Calculator class so it can be used as an object later in the program code. Create a custom method within the Calculator class (the lower one) called "Multiply", with two incoming integer parameters called "first" and "second". In the Multiply method, write code that will multiply the first incoming parameter ("first") times the second incoming parameter ("second") and return the result. (Tip: Create an integer variable called "total" within the method to store the result of the calculation, then send the total back with the return command.) Create additional methods called "Add", "Subtract", and "Divide". Write code within each method to perform the relevant calculation (addition, subtraction, and division). The customer wants only the multiplication result to be displayed at this time. (Note: The other three methods will be tested when you submit the project for grading.) From Main(), display the results of the multiplication command in the following way (exactly): Important Notes (READ CAREFULLY!): This program does not require either a loop or an IF statement. Only the shell of the custom class is provided, so you will need to write the entire methods, including the declaration lines. Be careful to name them according to the instructions (step 6). Any difference in the name will cause the grading algorithm to not see your method. (Tip: A review of the default code from the Unit 2 Lab Assignment may be helpful.) import java.util.Scanner; public class LabProgram { public static void main(String[] args) { /* Type your code below this line. Create additional lines as needed. */ } // do not delete this line } // do not delete this line class Calculator { /* Type your code below this line. Create additional lines as needed. */
Supreeta N.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD