1. Write C++ statements that prompt the user to enter a person’s last name and then store the last name into the variable name.
1. Write a program that prompts the capacity, in gallons, of an automobile fuel tank and the miles per gallon the automobile can be driven. The program outputs the number of miles the automobile can be driven without refueling.
Write a for statement to add all the numbers divisible by 3 or 5 between 1 and 1000.
1. Write a program that prompts the user to enter five test scores and then prints the average test score. (Assume that the test scores are decimal numbers.)
1. Write C++ statements that produce the following output:
Name: //output the value of the variable name
Pay Rate: $ //output the value of the variable rate
Hours Worked: //output the value of the variable
//hoursWorked
Salary: $ //output the value of the variable wages
For example, if the value of name is "Rainbow" and hoursWorked is
45.50, then the output is:
Name: Rainbow
Pay Rate: $12.50
Hours Worked: 45.50
Salary: $568.75
Write a program that will display a menu for the user to select what computation
to use. And compute the required outputs for each option. (see below the sample
menu). Use functions for this program.
M EN U
A] Compute area and circumference of Circle
B] Compute area and perimeter of a Rectangle
C] Compute Surface area and volume of a Cylinder
D] exit
1. Exercise 2: Create a class building that has the public member floors,area, and occupants and a method areaperperson()respectively that display the area per person for building. In the main() method create two instance of building called house and office and display the area per person by division of area/occupants
1. Exercises: Write a class Book with three data members BookId, Pages and Price. It also contains the following member function: • The get() method is used to input values • The show() method is used to display values Object Oriented Programming using JAVA Lab Manual – Page 24|193 • The set() method is used to set the values of data members using parameters • The getPrice() method is used to return the value of price
this is prac 3:
Task You need to implement a program for a car salesman who wants to keep record of the cars he has for sale. For each car he keeps the following: Registration Number (always unique), Model,Colour and Price Implement the following classes Class Car It must have a constructor, the necessary Get and Set methods, as well as the following methods:public boolean isCheap()// returns TRUE if the car is selling for under R10000.00 public void decreasePrice(double Amount)// decreases the selling price by Amount public void Display()// displays the Registration Number and Price of a car Class CarList It must contain the standard methods you would expect in a list class. The class must be able to interact with a data file (in other words, get initial data from a data file, and write the final data to a data file), and uses ArrayLists to implement a list Application Class The application class must have methods that do the following
This part continues with last one:
Now add the following functionality Add a SortedState variable to your CarList class. SortedState = 1 if the list is sorted in ascending order of price, SortedState = 2 if the list in sorted in ascending order of Registration number and SortedState = 0 otherwise. Add a BinarySearch method to your list class (based on the Registration number). Adapt the existing Find method (in the list class) to use the BinarySearch method when the list is sorted in ascending order of Registration number, otherwise the LinearSearch method should be used. Use a sorting algorithm effectively in a new method in the application class that displays the details of the cheapest car. Change the add method in CarList to keep the list sorted in ascending order on price even when a new car is added to the list