[SOLVED] C++ C++ Assignment 1

$25

File Name: C++_C++_Assignment_1.zip
File Size: 188.4 KB

5/5 - (1 vote)

C++ Assignment 1

You should submit two cpp files, Q1_your_student_id.cpp and Q2_your_student_id.cpp to iSpace.

Q1

Consider any two points (x1, y1) and (x2, y2) on a 2-D coordinate plane, we can calculate the distance between these 2 points and the angle that the line makes with x-axis using the equations below:

Distance:
Angle:

In this question, which equation you should use depends on whether the last digit of your student ID number is odd or even, according to the table below:
If the last digit of your student ID number is
You should calculate
Odd
Distance
Even
Angle

1.1 Use the messages below to prompt for the users input of the coordinates of two points.The user inputs the x- and y-coordinate of a point in the same line separated by a space (You can assume that the users always enter numbers as the input for all the coordinates.):Input (x1, y1): 3.2 1.5Input (x2, y2): 17.5 14.2
1.2According to the equation you use in this question, the program calculates the distance or angle, and the result using the following output messages with 3 decimal accuracy.
The distance is 19.125 unitsor
The angle is 0.726 radians
Q2

In this question, a positive integer value is considered. By checking every 2 consecutive digits form the value, you are going to find thelargestorsmallest2-digit value according to the table below:

If the second last digit of your student ID number is
You should calculate
Odd
Largest 2-digit value
Even
Smallest 2-digit value

2.1 Use the messages below to prompt for the users input of any positive integer value with2 to 9 digits (You can assume that the users always enter integers when being asked for input, and the first digit of the input number is a non-zero value):
Input a positive integer with 2 to 9 digits: 462056843

Following 2.1 above, if the user inputs an invalid value, the following error messageshould be displayed, and the program should allow user to input again until a correctvalue is received:

Error: Out-of-range. Input again: 4Error: Out-of-range. Input again: 1462056843Error: Out-of-range. Input again: -46205Error: Out-of-range. Input again: 462056843

2.3 According to the value you find in this question, the program displays the 2-digit resultusing the following output messages (e.g. input value as shown in 2.1):
The largest 2-digit value is 84orThe smallest 2-digit value is 05

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] C++ C++ Assignment 1
$25