Reference no: EM131447454
Assignment
Problem 1:
Write a class named Car that has the following fields:
• yearModel: The yearModel field is an int that holds the car's year model.
• make: The make field is a String object that holds the make of the car.
• speed: The speed field is an int that holds the car's current speed.
In addition, the class should have the following methods :
• Constructor : The constructor should accept the car's year model and make as arguments.
These values should be assigned to the object 's yearModel and make fields. The constructor should also assign 0 to the speed field.
• Accessor: The appropriate accessor methods should be implemented to access the values stored in the object 's yearModel, make, and speed fields.
• accelerate: The accelerate method should add 5 to the speed field when it is called.
• brake: The brake method should subtract 5 from the speed field each time it is called.
Demonstrate the class in a program that contains a Car object, and then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and print it on a separate line. Then, call the brake method five times, each time printing the current speed of the car on a separate line.
Problem 2:
Design a Payroll class with the following fields:
• name : a String containing the employee's name
• idNumber: an int representing the employee's ID number
• rate: a double containing the employee's hourly pay rate
• hours: an int representing the number of hours this employee has worked
The class should also have the following methods :
• Constructor : takes the employee's name and ID number as arguments
• Accessors: allow access to all of the fields of the Payroll class
• Mutators: let the user assign values to the fields of the Payroll class
• grossPay: returns the employee's gross pay, which is calculated as the number of hours worked times the hourly pay rate.
Write another program that demonstrates the class by creating a Payroll object , then asking the user to enter the data for an employee in the order: name , ID number, rate, hours.
The program should then print out a statement in the following format (for example, if you had an employee named Chris Jacobsen with ID number 11111, who works for 5 hours at $10/hr):
Chris Jacobsen, employee number 11111, made $50.00 in gross pay.
Using text forming so that the gross pay is rounded to two decimal places.
Problem 3:
Write a Temperature class that will hold a temperature in Fahrenheit and provide methods to get the temperature in Fahrenheit, Celsius, and Kelvin. The class should have the following field:
• ftemp: a double that holds a Fahrenheit temperature.
The class should have the following methods :
• Constructor : The constructor accepts a Fahrenheit temperature (as a double ) and stores it in the ftemp field.
• setFahrenheit: The set Fahrenheit method accepts a Fahrenheit temperature (as a double ) and stores it in the ftemp field.
• getFahrenheit: Returns the value of the ftemp field as a Fahrenheit temperature (no conversion required)
• getCelsius: Returns the value of the ftemp field converted to Celsius. Use the following formula to convert to Celsius:
Celsius = (5/9) * (Fahrenheit - 32)
• getKelvin: Returns the value of the ftemp field converted to Kelvin. Use the following formula to convert to Kelvin:
Kelvin = ((5/9) * (Fahrenheit - 32)) + 273
Demonstrate the Temperature class by writing a separate program that asks the user for a Fahrenheit temperature. The program should create an instance of the Temperature class, with the value entered by the user passed to the constructor . The program should then call the object 's methods to display the temperature in the following format (for example, if the temperature in Fahrenheit was -40):
The temperature in Fahrenheit is -40.0
The temperature in Celsius is -40.0
The temperature in Kelvin is 233.0.
Distinguish between dependency and delinquency
: The historical development of the juvenile justice system. Use case law or legislation to strengthen your discussion.Predominant philosophy of the juvenile system.Key differences between the juvenile and adult systems.Distinguish between dependency a..
|
Components of ad are rising and which are dropping
: Examine all four components of GDP (C, I, G, and Xn). Which of these four components of AD are rising and which are dropping? On the top righthand corner of the page, you can click on Modify to select prior years.
|
What rate have sales been growing
: Shalit Corporation's 2013 sales were $12 million. Its 2008 sales were $6 million. At what rate have sales been growing? Suppose someone made this statement: "Sales doubled in 5 years. This represents a growth of 100% in 5 years; so dividing 100% by 5..
|
Briefly describe how a visual was used to address a business
: Applying Visual Design Principles, Review one of the client stories in the portfolio section of the Xplane website ( www.xplane.com/portfolio ). Briefly describe how a visual was used to address a business problem and why a visual approach worked ..
|
Demonstrate the class in a program that contains car object
: Demonstrate the class in a program that contains a Car object, and then calls the accelerate method five times. After each call to the accelerate method.
|
What observations can you make about the use of law
: Over 50 years have passed since the Brown decision and while many things have changed, there are still inequalities within and between school districts, and within larger society. What observations can you make about the use of the law to effect ..
|
Briefly describe technologies that are leading businesses
: Briefly describe the technologies that are leading businesses into the third wave of electronic commerce. Define "channel conflict" and describe in one or two paragraphs how a company might deal with this issue
|
Monopolist produces the competitive output
: A monopolist's cost function is C(y)=y(y/50-2)²+y. It faces a demand function y=100-25p. Solve for monopolist's output, price, profit and consumer surplus when :
|
Currently saving for the down payment
: You want to buy a house within 3 years, and you are currently saving for the down payment. You plan to save $5,000 at the end of the first year, and you anticipate that your annual savings will increase by 10% annually thereafter. Your expected annua..
|