Java Programming
8th Edition
ISBN: 9781305981829
Author: Joyce Farrell
Publisher: Cengage Limited
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 2, Problem 9PE
a.
Program Plan Intro
Chili Dinner
Program Plan:
- Import the required java package.
- Define the class “ChiliToGo”.
- Define the main method.
- Declare named constant variables.
- Create a scanner class object to get user input.
- Prompt the user to enter number of adult meals.
- Convert the user input and store it in a variable.
- Prompt the user to enter number of child meals.
- Convert the user input and store it in a variable.
- Compute total price of adult meals and child meals and the grand total.
- Display total price of adult meals and child meals and the grand total.
b.
Program Plan Intro
Chili Dinner Profit
Program Plan:
- Import the required java package.
- Define the class “ChiliToGo”.
- Define the main method.
- Declare named constant variables.
- Create a scanner class object to get user input.
- Prompt the user to enter number of adult meals.
- Convert the user input and store it in a variable.
- Prompt the user to enter number of child meals.
- Convert the user input and store it in a variable.
- Compute total price of adult meals and child meals and the grand total.
- Compute profit of adult meals and child meals and the grand total.
- Display total price and profit of adult meals and child meals and the grand total.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The Huntington Boys and Girls Club is conducting a fundraiser by selling chili dinners to go. The selling price is Rs.7
for an adult meal and Rs.4 for a child's meal. Write a class that accepts the number of each type of meal ordered and
display the total money collected for adult meals, children's meals, and all meals. Moreover, assume the cost price to
produce an adult meal and a child's meal are Rs.4.35 and Rs. 3.10, respectively. Further, create a method to display
the total profit for each type of meal as well as the grand total profit.
Use java
Instructor note:
This lab is part of the assignment for this chapter.
This lab uses two Java files, LabProgram.java and SimpleCar.java. The SimpleCar class has been developed and provided to you already. You don't need to change anything in that class. Your job is to use the SimpleCar class to complete the specified tasks in the main() method of LabProgram.java
Given two integers that represent the miles to drive forward and the miles to drive in reverse as user inputs, create a SimpleCar object that performs the following operations:
Drives input number of miles forward
Drives input number of miles in reverse
Honks the horn
Reports car status
The SimpleCar class is found in the file SimpleCar.java.
Ex: If the input is:
100 4
the output is:
beep beep Car has driven: 96 miles
Use the scenario below for help answering 1(A), (B) and (C). This is using Java.
The Scenario:
You have a class named HeartsPlayer
A round of Hearts starts with every player having 13 cards
Players then choose 3 cards to “trade” with a player (1st you pass left, 2nd you pass right, 3rd you pass across, 4th you keep)
Players then strategically play cards in order to have the lowest score
At the end of the round, points are cumulatively totaled for each player.
If one player’s total is greater than 100, the game ends and the player with the lowest score wins.
Guide: Static & Not Final Field: Accessed by every object, Changing
Non-Static & Final Field: Accessed by object itself, Non-Changing
Static & Final: Accessed by every object, Non-Changing
Non-Static & Not Final Field: Accessed by object itself, Changing
1. How should the following data fields be defined (with respect to final and static)?
(a) playerPosition (These have values of North, South, East, or West)- Is…
Chapter 2 Solutions
Java Programming
Ch. 2 - Prob. 1RQCh. 2 - Prob. 2RQCh. 2 - Prob. 3RQCh. 2 - Prob. 4RQCh. 2 - Prob. 5RQCh. 2 - Prob. 6RQCh. 2 - Prob. 7RQCh. 2 - Prob. 8RQCh. 2 - Prob. 9RQCh. 2 - Prob. 10RQ
Ch. 2 - Prob. 11RQCh. 2 - Prob. 12RQCh. 2 - Prob. 13RQCh. 2 - Prob. 14RQCh. 2 - Prob. 15RQCh. 2 - Prob. 16RQCh. 2 - Prob. 17RQCh. 2 - Prob. 18RQCh. 2 - Prob. 19RQCh. 2 - Prob. 20RQCh. 2 - Prob. 1PECh. 2 - Prob. 2PECh. 2 - Prob. 4PECh. 2 - Prob. 5PECh. 2 - Prob. 6PECh. 2 - Prob. 7PECh. 2 - Prob. 8PECh. 2 - Prob. 9PECh. 2 - Prob. 10PECh. 2 - Prob. 11PECh. 2 - Prob. 12PECh. 2 - Prob. 1GZCh. 2 - Prob. 2GZCh. 2 - Prob. 1CPCh. 2 - Prob. 2CP
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- not handwritten Explain Meadowdale Dairy Farm sells organic brown eggs to local customers. They charge $3.25 for a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a class that prompts a user for the number of eggs in the order and then display the amount owed with a full explanation. For example, typical output might be, "You ordered 27 eggs." "That's 2 dozen at $3.25 per dozen and 3 loose eggs at 45.0 cents each for a total of $7.85."arrow_forwardThis is Java. This is a beginner course.arrow_forwardJava. Create UML class diagrams for the RoomDimension and RoomCarpet classes for the problem described below: The Westfield Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor by the price per square foot of carpet. For example, the area of floor that is 12 feet long and 10 feet wide is 120 square feet. To cover that floor with carpet that costs $8 per square foot would cost $960. (12 x 10 x 8 = 960.) First, you will create a class named RoomDimension that has two fields, one for the length of the room and one for the width. The RoomDimension class will have a method that returns the area of the room and a toString method. Next you will create a RoomCarpet class that has a RoomDimension object as a field. It will also have a field for the cost of the carpet per square foot. The RoomCarpet class will have a method that returns the total cost of the…arrow_forward
- Use java See the image for requirementsarrow_forward1)The program should be written in JAVA. Create a "Car" class that keeps car ids and prices. And create a "Galleries" class that holds the car list for a particular gallery. In this class there should be methods for get / set and print for car name, car number and car list. Adding / Removing Cars to the List in This Class should have methods. And create another method to find and print the IDs of Cars with Car Segment equal to X. (print_id(X)). Car Prices are as follows according to the segments. 0$-19999$ -> Z20000$-29999$ -> Y30000$-44999$ -> T45000$-100000$ -> P Apply the Car list using "Singly Linked List"(Node, newNode, head).arrow_forwardPlease help me out with this java problem! Thanks!arrow_forward
- Do the code in java and please dont plagarise or copy from others do it on your own and follow the instructions please thank you.arrow_forward- Challenge Activity 1: Stadium Seating Revenue Calculation Tool There are three seating categories at a stadium. Class A seats cost $20, Class B seats cost $15, and Class C seats cost $10. Write a program (a GUI program) ON *PYTHON*that asks how many tickets for each class of seats were sold, then displays the amount of income generated from ticket sales.arrow_forwardcomputer programmingarrow_forward
- Roll number is 021. Language: Java All instructions are given in pictures. Kindly gives all screenshots.arrow_forwardProgram - Python Make a class.The most important thing is to write a simple class, create TWO different instances, and then be able to do something. For example, create a pizza instance for Suzie, ask her for the toppings from the choices, and store her pizza order. Then create a second pizza instance for Larry, ask for his toppings and store his pizza order. Then print both of their orders back out. You do not need to make your class very complicated. (Shouldn't be the pizza example but something similar)arrow_forwardCan you help me write a program for this please: Create a class of songs. The class should be called Song and eachobject in this class represents a song. (This class could be used, for example, in a music library.) Each song has a title, an artist and a recordingyear. The title and artist are strings and both can consist of multiple words.The year is an integer.Your class should be designed by using the principle of encapsulation. Inother words, the data should be private.Create the following operations for this class of objects:(a) A function print(s, out) that prints song s to output stream outin the following format:TitleArtistYear1Three complete lines are printed. The stream argument has cout asa default value.(b) A function read(s, in) that reads song s from input stream in.The data in the stream is assumed to be in the format specifiedfor print. In particular, three complete lines are read. No errorchecking is performed. The stream argument has cin as a defaultvalue.(c) A…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY