0% found this document useful (0 votes)
5 views

Assignment 1 CPP

The document provides instructions for an assignment to create 6 programs across 6 parts. The programs include calculating averages, a basic calculator, displaying personal information, calculating percentages, currency conversion, calculating cylinder volume, various math functions, student information display, zoo ticket pricing, currency conversion, basic calculator, averaging test scores, guessing a secret number, storing and displaying student data, calculating a matrix, functions to calculate math operations and shapes areas.

Uploaded by

Minh Hoàng
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Assignment 1 CPP

The document provides instructions for an assignment to create 6 programs across 6 parts. The programs include calculating averages, a basic calculator, displaying personal information, calculating percentages, currency conversion, calculating cylinder volume, various math functions, student information display, zoo ticket pricing, currency conversion, basic calculator, averaging test scores, guessing a secret number, storing and displaying student data, calculating a matrix, functions to calculate math operations and shapes areas.

Uploaded by

Minh Hoàng
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT 1 CPP

Prepared by Dr Han Duy Phan.

Submission instruction: Create a folder (A1_StudentName_StudentID) that contains 6 sub folders for each
part. Each sub folder contains all the solutions for the corresponding tasks. Compress the
A1_StudentName_StudentID folder and submit A1_StudentName_StudentID.zip to Moodle.

Part 1

● Task 1: Write a simple program to calculate & display the average of three integer numbers
● Task 2: Write a simple calculator to calculate & display the summation, subtraction, division, modulus,
multiplication of two numbers
● Task 3: Write a simple program to display your personal information in a nice presentation that you
design.
● Task 4: Write a simple program to calculate and display x percentage of a number y.

Part 2

● Task 1: Write a simple software that takes a number in USD from user input and convert it into VND
then prints two results on the screen in a nice format.
● Task 2: Write a simple software that takes the radius and height of a cylinder, then calculate its volume
and display the information on the screen in a nice format.
● Task 3: Write a simple calculator that takes one number from the user then calculates and displays its
abs, sin, cos, tan, log, log10, sqrt, exp.
● Task 4: Write a simple software that takes from user input basic information of a student including full
name, day of birth, hometown, major, … then display this information on the screen in a nice format.

Part 3

● Task 1: Write a simple software that asks for user’s age then calculates the zoo ticket cost based on
the given age: if age < 5 then ticket is free, if age is between 5 and 10 then ticket costs $10, if age is
between 11 and 16 then ticket costs $20, if age is greater than 16 then ticket costs $25. Display the
ticket price information for the user to see.
● Task 2: Write a simple software that asks for user input for the amount of money in VND, then asking
their choice of currency conversion to AUD or USD: (1) for AUD and (2) for USD. Do the calculation
and show the corresponding information based on their choice.
● Task 3: Write a simple calculator that asks for user input for two numbers and their choice of an
operator (+, -, *, /) then calculates and displays the information accordingly.

Part 4

● Task 1: Write a simple software that takes the scores of 10 students (using for loop), then calculate the
average score and display on the screen
● Task 2: Write a simple software that keeps asking the user to make a guess of a secret number
between 0 and 20 (the program knows this number, but the user does not). At each iteration the
program gives the feedback on the screen (greater or smaller) when comparing the user guess with the
secret number. The program finishes when the user guesses the secret number correctly.

Part 5

● Task 1: Write a simple software that takes from the user input students’ names and their scores
(0-100), storing these values into two arrays until the user indicates that they want to stop with ‘-1’.
Assume that the maximum number of students is 100. Also use another array to store the status of
passed (score >= 50) or failed (score < 50) of the above students. Once the data entering process
finishes, display the students’ names, scores, and passed/failed status nicely in 3 columns.
● Task 2: Write a simple software that takes from the user input elements of a 4x4 square matrix and
store them in a two-dimensional array. Display on the screen the matrix with all of its elements in a nice
table format, the sum of all elements in the matrix, the sum of all elements in each row, the sum of all
elements in each column, and the sum of all elements in each diagonal. The first easier approach is to
manually indicate each element’s index. The second approach is to use for loops to go through the
correct elements automatically.

Part 6

● Task 1: Write three functions sumTripple, mulTripple, aveTriple that take three input parameters which
are three float numbers then calculate and return the sum, the multiplication, and the average of three
numbers. Write a program that keeps asking for three numbers from user input, then calls the three
functions above to calculate the return values, after that displays the return values on the screen. This
process is finished when the user enters ‘-1’.
● Task 2: Write four functions that calculate and return the areas of a square, a rectangle, a circle, and a
triangle. You need to decide the appropriate parameters for each of these four functions. Write a
software that lets the user choose each of these four functionalities and use it (you also need to let the
user enter appropriate parameters for the chosen function). This process is finished when the user
enters ‘-1’.

You might also like