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

Assignment 2

This document provides instructions for Assignment 2 in Introduction to Computing. It is due by November 12, 2019 at 9:00 am. Students must complete 4 questions in separate C++ files named task1.cpp, task2.cpp, etc. and submit only the files to the LMS. Late submissions will lose 10% per hour. Plagiarism will result in zero marks. Question 1 involves declaring variables and performing calculations. Question 2 converts elapsed time in seconds to hours, minutes, seconds. Question 3 calculates the average of 5 test scores. Question 4 separates the digits of a 3-digit number entered by the user.

Uploaded by

Siddique Rana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Assignment 2

This document provides instructions for Assignment 2 in Introduction to Computing. It is due by November 12, 2019 at 9:00 am. Students must complete 4 questions in separate C++ files named task1.cpp, task2.cpp, etc. and submit only the files to the LMS. Late submissions will lose 10% per hour. Plagiarism will result in zero marks. Question 1 involves declaring variables and performing calculations. Question 2 converts elapsed time in seconds to hours, minutes, seconds. Question 3 calculates the average of 5 test scores. Question 4 separates the digits of a 3-digit number entered by the user.

Uploaded by

Siddique Rana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Deadline: Nov 12, 2019 09:00 a.m.

Introduction to Computing
Assignment 2
Instructions
• Create separate file for each task. And name each file as task1.cpp, task2.cpp, task3.cpp ….
• Please follow the deadline. In case of late submission, marks will be deducted. On late submission of every
hour, 10% marks will be deducted.
• Submit assignment on LMS only in specified folder “Assignment 2 – Submission Folder”. No hard copy will be
accepted. Do not zip folder or submit folder. Only submit cpp files
• If plagiarism found, zero marks will be awarded. Consider this instruction as last warning, don’t ask for second
warning!

Note: Question 1 is only lengthy but not difficult at all. The purpose of this question is to check how well you
have understood the concepts of programming.
Question 1
Perform the following instructions in C++ to solve the problem

• Write C++ statements that declare and initialize the following named variables: SECRET of type int initialized to 11
and RATE of type double initialized to 12.50.
• Write C++ statements that declare the following variables: num1, num2, and newNum of type int; and
hoursWorked and wages of type double.
• Write C++ statements that prompt the user to input two integers and store the first number in num1 and the
second number in num2.
• Write a C++ statement(s) that outputs the values of num1 and num2, indicating which is num1 and which is num2.
For example, if num1 is 8 and num2 is 5, then the output is: The value of num1 = 8 and the value of num2 = 5.
• Write a C++ statement that multiplies the value of num1 by 2, adds the value of num2 to it, and then stores the
result in newNum. Then, write a C++ statement that outputs the value of newNum.
• Write a C++ statement that updates the value of newNum by adding the value of the variable SECRET. Then, write
a C++ statement that outputs the value of newNum with an appropriate message.
• Write C++ statements that prompt the user to enter a decimal number between 0 and 70 and then store the
number entered into hoursWorked.
• Write a C++ statement that multiplies the value of the variable RATE with the value of hoursWorked and then
stores the result into the variable wages.
• Write C++ statements that produce the following output:
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

Question 2
Write a C++ program that prompts the user to input the elapsed time for an event in seconds. The program then outputs
the elapsed time in hours, minutes, and seconds.

Example: If the elapsed time is 9630 seconds, then the output is 2:40:30.

Question 3

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
Deadline: Nov 12, 2019 09:00 a.m. Introduction to Computing
Assignment 2
Example

Please enter five test scores: 15 20 30 40 50


The average test score is 31

Question 4

Write a program in C++ that asks a user to enter exactly 3-digit number. Separate the digits and display on console screen.
Hint: you may use % operator to solve this.

Example

Please enter 3-digit number: 549


The digits after separation are 5 4 9

Good Luck!

You might also like