implement the class Loan with the following requirements:
•
A member variable that will hold the annual interest rate of the loan. Its default value will be 2.5.
•
A member variable that will hold the number of years for the loan. Its default value will be 1.
•
A member variable that will hold the loan amount. Its default variable will be 1000.
•
A default constructor.
•
Another constructor that has interest rate, years, and loan amount as its parameters.
•
A member function that returns the annual interest rate of this loan.
•
A member function that returns the number of the years of this loan.
•
A member function that returns the amount of this loan.
•
A member function that sets a new annual interest rate to this loan.
•
A member function that sets a new number of years to this loan.
•
A member function that sets a new amount to this loan.
•
A member function that returns the monthly payment of this loan.
•
A member function that returns the total payment of this loan.
Implementing using
class Loan
Sample Run:
Enter yearly interest rate, for example 8.25: 10
Enter number of years as an integer, for example 5: 5
Enter loan amount, for example 120000.95: 300000
The monthly payment is 6374.11
The total payment is 382446.80
Create a class called Register with three instance variables: username, email, and password. These three pieces of information are all String. Your class should have a constructor that initializes the three instance variables and assumes that the provided values are correct. For each instance variable, provide a set and a get method. Create a displayInformation method in order to display the username, email, and password, separated by a comma ( , ). Create a test application called RegistrationInfoTest that demonstrates the Register class.
Calculate and display the sum of all the numbers divisible by 7 between 18 and 534 using loops and conditional statements i.e. 21+28+35+...+525+532.
Q5: Create a list containing the following 3 elements:
your favorite color
the number of pets you have
a boolean value describing whether you have previous programming experience
Q6: Complete the following print and if statements by accessing the appropriate elements from my_list.
Hint: Use the list indexing notation [].
print('My favorite color is', ???) print('I have {} pet(s).'.format(???)) if ???:
print("I have previous programming experience") else:
print("I do not have previous programming experience")
Q7: Add your favorite single digit number to the end of the list using the appropriate list method.
Q8: Remove the first element of the list, using the appropriate list method.
Q9: Complete the print statement below to display the number of elements in my_list. print("The list has {} elements.".format(???))
Q11: A travel company wants to fly a plane to the Bahamas. Flying the plane costs 5000 dollars. So far, 29 people have signed up for the trip. If the company charges 200 dollars per ticket, what is the profit made by the company?
Fill in values or arithmetic expressions for the variables below.
cost_of_flying_plane = ??? number_of_passengers = ??? price_of_ticket = ???
profit = ???
print('The company makes of a profit of {} dollars'.format(profit))
Q11b Out of the 29 people who took the flight, only 12 buy tickets to return
from the Bahamas on the same plane. If the flying the plane back also costs 5000 dollars, and does the company make an overall profit or loss? The company charges the same fee of 200 dollars per ticket for the return flight. (Optional)
Use an if statement to display the result.
Write a C++ program to find sum of all even numbers between 1 to n. – using for loop
Write a C++ program to print all even numbers between 1 to 100. - using while loop
2.
Assume that each of the following statements applies to the same program.
a.
Write a statement that opens file
oldmast.dat
for
input; use an ifstream object called
inOldMaster.
b.
Write a statement that opens file
trans.dat
for reading
and writing data to it; use fstream object
transFile
that can read data from the file trans.dat
as well as write data to it.
c.
Write a statement that writes a record to the transfile. The record to store consist of an integer data
accountNumber
, and a floating point data
dollarAmount
Find the error(s) and show how to correct it(them) in each of the following.
a.
File
pets.dat
that stores its id, name, age and owner
of the pet is referred to by ofstream object
petfile
.
petfile>>pet_id>>pet_name>>pet_age>>pet_owner;
b.
The following statement should create an ifstream object
salesfile
that refers to the file
weeklysales.dat
that contains data about the id the
salesperson, total sales generated, and the
week number, read the data from the file and display it on the console output.
ifstream salesfile(“weeklysales.dat”);
int id,wk;
float sales;
salesfile>>id>>wk>>sales;
while (!salesfile.eof()){
cout<<id<<”\t”<<sales<<”\t”<<wk<<”\n”;
salesfile<<id<<wk<<sales;
}