question archive C++ Programming
Subject:Computer SciencePrice:4.87 Bought7
C++ Programming. Write C++ statement to accomplish each of the following:
a. Initialize the currency with dollar symbol
b. Initialize the total working hours per person in one week is 43.5
c. Initialize the academic status of a student is Active
d. Initialize value for x is 21.9 and value for y is 5
e. Initialize the government service tax is 7%
f. Compute the sum of three integer numbers that contains variables a,b,c and assign the result to the variable sum
g. Assign the value of variable val1 and multiply with 2 to the variable total_value
h. Calculate average marks of 23 students in a class and assign the variable total marks divided by total number of students to the variable average
i. Define service charge as 6%
j. Define currency rate for 1 Australian dollar as 2.94 Malaysian ringgit
k. Define 1 Celsius equivalent to 33.8 Fahrenheit
l. Define parking rate per entry as RM5
m. Define constant discount rate 15% for any goods purchased above RM200
n. Given the value for width = 5cm and height =10cm, find the perimeter of two rectangles
o. Define Pi value as 3.42
p. Constant called FALSE which has value
q. Constant speed of sound at sea level 340.29 m/s
Answer:
a)
char currency='$';
b)
float working_hours=43.5;
c)
string academic_status="Active";
d)
float x=21.9;
int y=5;
e)
float govt_service_tax=0.07;
f)
sum=a+b+c;
g)
total_value=val1*2;
h)
The marks of 23 students are stored in array
so, we can use a loop to calculate the total marks
float total_marks=0.0;
for(int i=0;i<23;i++)
total_marks+=arr[i];
float average=total_marks/23;
i)
float service_charge=0.06;
j)
float australian_dollar=2.94*malaysian_ringgit;
k)
float celsius=33.8*fahrenheit;
l)
float parking_rate=0.05;
m)
if(goods_price>200)
const float discount_rate=0.15;
n)
int width=5;
int height=10;
int perimeter=2*(width+height);
o)
const float PI=3.42;
p)
const int FALSE=1;
q)
const float speed=340.29;