Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views3 pages

Home1 23ECE

The document outlines the requirements for Homework 1, which includes submitting assignments in .txt or .cpp format with a specific naming convention. Students are prohibited from using AI tools like ChatGPT and must complete at least half of the questions, including a designated red question. The homework consists of several programming tasks in C++, including variable manipulation, error correction, conditional operations, and class creation.

Uploaded by

vunguyenhongson3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Home1 23ECE

The document outlines the requirements for Homework 1, which includes submitting assignments in .txt or .cpp format with a specific naming convention. Students are prohibited from using AI tools like ChatGPT and must complete at least half of the questions, including a designated red question. The homework consists of several programming tasks in C++, including variable manipulation, error correction, conditional operations, and class creation.

Uploaded by

vunguyenhongson3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Homework 1

Please submit the homework via .txt files or .cpp files


Name your file with the following Syntax:
HoVaTen_class_studentID
Ex: DoanMinhHieu_22ECE_123220009

It is prohibited to use ChatGPT or anything AI-related.


It is prohibited to copy off your friends.
Do at least half of the given questions and the red question.
Try your best!
1. Convert the following into C++ code.
a. Store 20 in a speed variable.
Store 10 in a time variable.
Calculate the distance variable.
Display the content of the distance variable on the screen.

b. Store 172.5 in a force variable.


Store 27.5 in an area variable.
Calculate pressure. (Divide area by force)
Display the pressure variable on the screen.

2. Find the error.

include iostream
using namespace std;
int main();
{
int a, b, c \\interger
a = 3
b = 4
c = a + b
cout < "The value of c is %d" < c;
return 0;
}

3. Minmax.
Write a program that asks the user to enter two numbers. The program
should use the conditional operator to determine which number is
smaller and which is larger and print it out on the screen.
Take note: The number needs to always be positive, if not, ask the user
to enter again
4. Final of Computer Programming 1 of 22ECE.
Write a program to find, calculate, and print the sum of all odd
numbers of a string of numbers entered by the user.
Ps: please remember the function of % and / operation!
5. Larger Than n
In a program, write a function that accepts three arguments: an array,
the size of the array, and a number n. Assume that the array contains
integers. The function should display all of the numbers in the array
that are greater than the number n.
6. Employee Class (You must do this question)
Write a class named Employee that has the following member variables:
- name. A string that holds the employee’s name
- idNumber. An int variable that holds the employee’s ID number
- department. A string that holds the name of the department where
the employee works.
- position. A string that holds the employee’s job title.
The class should have the following constructors:
- A constructor that accepts the following values as arguments and
assigns them to the appropriate member variables: employee’s
name, employee’s ID number, department, and position.
- A constructor that accepts the following values as arguments and
assigns them to the appropriate member variables: employee’s name
and ID number. The department and position fields should be
assigned an empty string ("").
- A default constructor that assigns empty strings ("") to the
name, department, and position member variables, and 0 to the
idNumber member variable.
Write appropriate mutator functions that store values in these member
variables and accessor functions that return the values in these
member variables. Once you have written the class, write a separate
program that creates three Employee objects to hold the following
data.

The program should store this data in the three objects and then
display the data for each employee on the screen.

You might also like