代写COMP 3141: Object Oriented Design and Programming Assignment 1调试C/C++语言

2024-09-02 代写COMP 3141: Object Oriented Design and Programming Assignment 1调试C/C++语言

COMP 3141: Object Oriented Design and Programming

Assignment 1 (10%)

Programming Questions for Module 1, Module 2 and Module 3

Instructions:

There are 2‐3 questions in each week. For each question, design, compile and run the program.  

Submission Method:

In your computer, make subfolders named Module 1, Module 2 and Module 3. Save all the files you develop for the questions into the appropriate folder. Once all the questions of the assignment are complete, zip the folders into ONE zip file titled Assignment 1 and send it to the Open Learning Faculty Member for marking.  

Module 1

Question 1

Write a C++ program that asks the user to enter radius of the circle. The program must print circle’s diameter, area and circumference. Use the Pi value as 3.14 for all calculations. Do all calculations in the output statement.

Question 2

Write a C++ program that asks the user to enter two integers. Obtain the numbers from the user, and then print the larger number followed by the words “is larger.” If the numbers are equal, print the message “The numbers are equal”.  

Question 3

(Car‐Pool Savings Calculator) Research several car‐pooling websites. Create an application that calculates your daily driving cost, so that you can estimate how much money could be saved by car pooling, which also has other advantages such as reducing carbon emissions and reducing traffic congestion. The application should input the following information and display the user’s cost per day of driving to work:

a) Total miles driven per day.  

b) Cost per gallon of gasoline.

c) Average miles per gallon.  

d) Parking fees per day.

e) Tolls per day.

Module 2

Question 1

Write a C++ program to input an integer number (up to 5 digits). The inputted number should be broken into separate digits and do two calculations on that:

1. Check if it is palindrome or not  

2. Find the sum of all the digits as a single digit number.

Question 2

(Date Class) Create a class called Date that includes three instance variables—a month (type int), a day (type int) and a year (type int). Provide a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate that displays the month, day and year separated by forward slashes (/). Write a test application named DateTest that demonstrates class Date’s capabilities.

Question 3

Write a Code to take the user input for n and print the sum of equation  

1 + 1/1! + 2/2! + 3/3! + 4/4! Till 4/n!

Module 3

Question 1

Write a C++ program that will run as a random guessing game. The game is to generate a random number from 1‐100. The player/guesser needs to guess the number. Computer checks the guessers guess and compares with the number generated:

The different messages can be:

You are too cold on lower side  (display ‐‐‐‐‐)

You are hot on lower side (display ‐‐‐)

You are hot on the upper side (display +++)

You are too cold on the upper sire (display +++++)

YOU ARE THERE (######YOU WON ####)

Question 2

(Sales Commission Calculator) A large company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or a total of $650. Develop a C++ program that uses a while statement to input each salesperson’s gross sales for last week and calculates and displays that salesperson’s earnings. You must process one salesperson’s figures at a time.

Question 3

Open prog12.cpp and convert that to run through functions for calculating the areas of circle, triangle, rectangle and square.