Microsoft Visual C#
7th Edition
ISBN: 9781337102100
Author: Joyce, Farrell.
Publisher: Cengage Learning,
expand_more
expand_more
format_list_bulleted
Question
Chapter 9, Problem 9RQ
Program Plan Intro
Program Plan:
To find the correct answer from the given set of options.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
JAVA
solve in python
Street ClassStep 1:• Create a class to store information about a street:• Instance variables should include:• the street name• the length of the street (in km)• the number of cars that travel the street per day• the condition of the street (“poor”, “fair”, or “good”).• Write a constructor (__init__), that takes four arguments corresponding tothe instance variables and creates one Street instance.
Street ClassStep 2:• Add additional methods:• __str__• Should return a string with the Street information neatly-formatted, as in:Elm is 4.10 km long, sees 3000 cars per day, and is in poor condition.• compare:• This method should compare one Street to another, with the Street the method is calledon being compared to a second Street passed to a parameter.• Return True or False, indicating whether the first street needs repairs more urgently thanthe second.• Streets in “poor” condition need repairs more urgently than streets in “fair” condition, whichneed repairs more…
Need a java code
Create a class called SingleItem
This class represents a bag that can hold any single type of object (decided at bag-creation time), and only one item of that type at a time. You may have a zero-parameter constructor if you want one, but you must have the following three features:
Add a method called (addItem()) which returns whether or not it was successfully added
Add a method which removes an item from the bag and returns it (deleteAnItem()), return null if there is no item
Add a method to check if an item is in the bag (hasAnIteminTheBag()) which returns true or false
Chapter 9 Solutions
Microsoft Visual C#
Ch. 9 - Assume that you have created a class named...Ch. 9 - Prob. 9RQCh. 9 - Assume that you have created a class named...Ch. 9 - Create an application named SalesTransactionDemo...Ch. 9 - Create an application named CarDemo that declares...Ch. 9 - Create a program named SalesTaxDemo that declares...Ch. 9 - Prob. 8ECh. 9 - Write a program named DemoJobs for Harolds Home...Ch. 9 - a. Write a FractionDemo program that instantiates...Ch. 9 - Prob. 1DE
Knowledge Booster
Similar questions
- This is the tester of two classesarrow_forwardIn previous chapters, you have created programs for the Greenville Idol competition. Now create a Contestant class with the following characteristics: The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing Dancing, Musical instrument, and Other. The class contains an auto-implemented property that holds a contestants name. The class contains fields for a talent code and description. The set accessor for the code assigns a code only if it is valid. Otherwise, it assigns I for Invalid. The talent description is a read-only property that is assigned a value when the code is set. Modify the GreenvilleRevenue program so that it uses the Contestant class and performs the following tasks: The program prompts the user for the number of contestants in this years competition; the number must be between 0 and 30. The program continues to prompt the user until a valid value is entered. The expected revenue is calculated and displayed. The revenue is $25 per contestant. The program prompts the user for names and talent codes for each contestant entered. Along with the prompt for a talent code, display a list of the valid categories. After data entry is complete, the program displays the valid talent categories and then continuously prompts the user for talent codes and displays the names of all contestants in the category. Appropriate messages are displayed if the entered code is not a character or a valid code.arrow_forwardDesign a class named StopWatch. The class contains:■ The private data fields startTime and endTime with get methods.■ A constructor that initializes startTime with the current time.■ A method named start() that resets the startTime to the current time.■ A method named stop() that sets the endTime to the current time.■ A method named getElapsedTime() that returns the elapsed time for thestop watch in milliseconds.Draw the UML diagram for the class, and then implement the class. Write a test program that measures the execution time of adding numbers from 1 to 1,000,000.arrow_forward
- class SavingsAccount(object): RATE = 0.02 def __init__(self, name, pin, balance = 0.0): self._name = name self._pin = pin self._balance = balance def __str__(self): result = 'Name: ' + self._name + '\n' result += 'PIN: ' + self._pin + '\n' result += 'Balance: ' + str(self._balance) return result def __eq__(self,a): if self._name == a._name and self._pin == a._pin and self._balance == a._balance: return True else: return False def __gt__(self,a): if self._balance > a._balance: return True else: return False def getBalance(self): return self._balance def getName(self): return self._name def getPin(self): return self._pin def deposit(self, amount): self._balance += amount return self._balance…arrow_forwardPlease see attached:)arrow_forward2. The MyInteger Class Problem Description: Design a class named MyInteger. The class contains: n [] [] A private int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int value. A get method that returns the int value. Methods isEven () and isOdd () that return true if the value is even or odd respectively. Static methods isEven (int) and isOdd (int) that return true if the specified value is even or odd respectively. Static methods isEven (MyInteger) and isOdd (MyInteger) that return true if the specified value is even or odd respectively. Methods equals (int) and equals (MyInteger) that return true if the value in the object is equal to the specified value. Implement the class. Write a client program that tests all methods in the class.arrow_forward
- Java - Access Specifiers Create a class named Circle that has attributes radius, area, and circumference and make the attributes private. Make a public method that sets the radius and a method that prints all attributes. Ask the user input for radius. Note: Use the PI from the math functions Inputs A line containing an integer 10 Sample Output Radius: 20 Area: 1256.64 Circumference: 125.66arrow_forwardFor your homework assignment, build a simple application for use by a local retail store. Your program should have the following classes: Item: Represents an item a customer might buy at the store. It should have two attributes: a String for the item description and a float for the price. This class should also override the __str__ method in a nicely formatted way. Customer: Represents a customer at the store. It should have three attributes: a String for the customer's name, a Boolean for the customer's preferred status, and a list of 5 indexes to hold Item objects. Include the following methods: make_purchase: accepts a String and a double as parameters to represent the name and price of an item this customer is purchasing. Create a new Item object with this info and append it to the internal list. If the customer is a preferred customer based on the Boolean attribute's value, take 10% off the total sale price. __str__: Override this method to print the customer's name and every…arrow_forward// This file defines the Building class// and the Hotel class that inherits from it.// A demonstration program declares and uses a Hotel object.class Building Declarations private string streetAddress private num squareFeet public string getAddress() return streetAddress public void getSquareFeet() return squareFt public void setSquareFeet() squareFeet = feet return public void setStreetAddress(string address) address = streetAddress returnendClass class Hotel inheritsFrom Building Declarations private num numberOfRooms public Hotel(string address, num sqFt, num rooms) streetAddress = address squareFeet = sqFt numberOfRooms = rooms return public num getNumberOfRooms return roomsendClass start Declarations Hotel hotel("100 Main Street", 8000, 20) output getAddress(), getSquareFeet(), getNumberOfRooms()stoparrow_forward
- Write the ScienceExam class so that the following code generates the output below: class Exam: def __init__(self,marks): self.marks = marks self.time = 60 def examSyllabus(self): return "Maths , English" def examParts(self): return "Part 1 - Maths\nPart 2 - English\n" engineering = ScienceExam(100,90,"Physics","HigherMaths") print(engineering) print('----------------------------------') print(engineering.examSyllabus()) print(engineering.examParts()) print('==================================') architecture = ScienceExam(100,120,"Physics","HigherMaths","Drawing") print(architecture) print('----------------------------------') print(architecture.examSyllabus()) print(architecture.examParts()) OUTPUT: Marks: 100 Time: 90 minutes Number of Parts: 4 ---------------------------------- Maths , English , Physics , HigherMaths Part 1 - Maths Part 2 - English Part 3 - Physics Part 4 - HigherMaths ================================== Marks: 100 Time: 120 minutes Number of Parts: 5…arrow_forwardIn Java Write a CashRegister class that can be used with the RetailItem class that you wrote inChapter 6’s Programming Challenge 4. The CashRegister class should simulate the sale ofa retail item. It should have a constructor that accepts a RetailItem object as an argument.The constructor should also accept an integer that represents the quantity of items beingpurchased. In addition, the class should have the following methods:• The getSubtotal method should return the subtotal of the sale, which is the quantitymultiplied by the price. This method must get the price from the RetailItem objectthat was passed as an argument to the constructor.• The getTax method should return the amount of sales tax on the purchase. The salestax rate is 6 percent of a retail sale.• The getTotal method should return the total of the sale, which is the subtotal plus thesales tax.Demonstrate the class in a program that asks the user for the quantity of items being purchased,and then displays the sale’s…arrow_forwardThis is object oriented programmingarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT