Write two methods to calculate the tip for a meal eaten at a restaurant. One method...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write two methods to calculate the tip for a meal eaten at a restaurant. One method has been partially provided for you. A server for an individual table at a restaurant is usually tipped between 15 and 20% of the cost of the meal. However, some restaurants don't leave the amount of the tip up to the customer and charge a fixed percentage of the meal. First, complete the calcTip method shown below that is based on the cost of the meal and percent of the customer's choice. Then, write a complete overloaded method called calcTip, which calculates the tip at the rate of 17.5%. //post condition: returns the amount of the tip public double calcTip (double percent, double mealCost) { } //complete the code for the first method here //second method to be written here. Question 4 (Essay Worth 6 points) Consider the following statement: double time = someObject.convertToSeconds (11.5) Write a partial class that shows a class constant and an instance method. Write an instance method that converts minutes to seconds using a class constant representing the number of seconds in one minute. The value passed to the method represents the amount of time in minutes. Paragraph AIA ✓ A ✓ A V 52 V 165 Tx B I SU X₂ X² PA 트 HTML i bh ✓ C Question 3 (Essay Worth 6 points) Write a class method called subtract These that will accept two integer values and calculate and return their difference. £3 • Add Audio V AIA ✓ A ✓ V Paragraph Add Video A ✓ V T BISU X₂ X² 2. 66 開く A HTML := = = EEEV G F Question 2 (Essay Worth 6 points) Consider the following segment of code: SomeClass someObject1 = new SomeClass (23); SomeClass someObject2 = new SomeClass (98.6); SomeClass someObject3 = new SomeClass (23, 98.6); Write the SomeClass class based on the statements above. Include any instance variables and the complete constructors, including the assignment of variables. (Other code exists in SomeClass but will not be written at this time.) रुले ave Paragraph LAIA A V A ✓ V I BI & U X₂ X² 52 66 開く 行 V HTML := !! - E✓ く v c ✓ C Write two methods to calculate the tip for a meal eaten at a restaurant. One method has been partially provided for you. A server for an individual table at a restaurant is usually tipped between 15 and 20% of the cost of the meal. However, some restaurants don't leave the amount of the tip up to the customer and charge a fixed percentage of the meal. First, complete the calcTip method shown below that is based on the cost of the meal and percent of the customer's choice. Then, write a complete overloaded method called calcTip, which calculates the tip at the rate of 17.5%. //post condition: returns the amount of the tip public double calcTip (double percent, double mealCost) { } //complete the code for the first method here //second method to be written here. Question 4 (Essay Worth 6 points) Consider the following statement: double time = someObject.convertToSeconds (11.5) Write a partial class that shows a class constant and an instance method. Write an instance method that converts minutes to seconds using a class constant representing the number of seconds in one minute. The value passed to the method represents the amount of time in minutes. Paragraph AIA ✓ A ✓ A V 52 V 165 Tx B I SU X₂ X² PA 트 HTML i bh ✓ C Question 3 (Essay Worth 6 points) Write a class method called subtract These that will accept two integer values and calculate and return their difference. £3 • Add Audio V AIA ✓ A ✓ V Paragraph Add Video A ✓ V T BISU X₂ X² 2. 66 開く A HTML := = = EEEV G F Question 2 (Essay Worth 6 points) Consider the following segment of code: SomeClass someObject1 = new SomeClass (23); SomeClass someObject2 = new SomeClass (98.6); SomeClass someObject3 = new SomeClass (23, 98.6); Write the SomeClass class based on the statements above. Include any instance variables and the complete constructors, including the assignment of variables. (Other code exists in SomeClass but will not be written at this time.) रुले ave Paragraph LAIA A V A ✓ V I BI & U X₂ X² 52 66 開く 行 V HTML := !! - E✓ く v c ✓ C
Expert Answer:
Answer rating: 100% (QA)
1 Calculate Tip Methods Here are two methods to calculate ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Factor by grouping. 4u +7u +20u+35
-
Financial aid debt and depression Restate the problem statement. Synthesize the results of your lens evaluations, data gathered, and interview results. Propose two recommendations to address the...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Implement the method contains() for HashST.
-
A slender rod of length L and weight W is attached to collars which can slide freely along the guides shown. Knowing that the rod is in equilibrium, derive an expression for the angle in terms of...
-
149. Polyembryony is reported in I. Citrus II. Mango Correct name are III. Gossypium (1) I and III (2) II and III (3) I, II and III (4) I and II 150. The wheat grain has an embryo with one large,...
-
Identify the important legal provisions governing information security and privacy in your country.
-
Qamar, Inc., did not pay dividends in 2009 or 2010, even though 50,000 shares of its 6.5%, $50 par value cumulative preferred stock were outstanding during those years. The company has 800,000 shares...
-
At December 3 1 , 2 0 2 2 , Samson Company reported Accounts Receivable of $ 1 0 5 , 0 0 0 and Allowance for Doubtful Accounts of $ 7 , 5 0 0 . On January 7 , 2 0 2 3 , Delilah, Inc. declares...
-
Describe three modern canons of statutory construction and three historical common law canons. Briefly distinguish formalism and realism as bases for the interpretation of legal texts. Explain the...
-
GinnyCo has pretax book and taxable income of $400,000 and reports a $100,000 income tax payable in the current year. GinnyCo has engaged in activities that it believes qualify for the research...
-
What are the key differences between aerobic and anaerobic respiration, particularly concerning the final electron acceptor and overall energy yield ? Explain
-
Music Matters are interested in understanding how their earnings relate to the overall Musical Instrument market. Your manager has asked you to explore the market earnings to support the developments...
-
Select one of the formats for analyzing, sorting, and interpreting data Research and discuss how the format is used in a business application. Provide an example in your discussion. Why do you think...
-
How does the process of cellular respiration facilitate the conversion of complex organic molecules into usable energy within eukaryotic cells ? Explain
-
Identify an example of a situation or experience that is able to explain about the social contract ethic.
-
In what way is followership related to the mission of the agency? Do Robin and her managers recognize the importance of followership? Explain.
-
Express these numbers in standard notation. a. 2.87 10-8 b. 1.78 1011 c. 1.381 10-23
-
How is a gain on bargain purchase accounted for?
-
Len Innsbruck is the accountant for Wallex Trucks. This entity has an 80% holding in the entity Tires R-Us. Len is concerned that the consolidated nancial statements prepared under IFRS 10 may be...
-
Economic interests (investments) held by governments in other entities fall into three broad categories: controlling interests, interests involving shared control, and portfolio investments. (a)...
-
A football is thrown on a long pass. Compared to the balls initial horizontal velocity component, the velocity at the highest point is (a) greater, (b) less, (c) the same.
-
What process do you follow to make decisions for these different circumstances, and are you satisfied with the results?
-
A football is thrown on a long pass. Compared to the balls initial vertical velocity, the vertical component of its velocity at the highest point is (a) greater, (b) less, (c) the same.
Study smarter with the SolutionInn App