Test 1 CSCI 151 Preparation

Question 1 (50 points):

For the program below, answer the following questions:


X = "C++"
C = "Java"
D = C+X
E = 15
K = 2
M = E/K
Y = E//K**2
Z = Y%10

Question 2 (50 points):

In spring 2015, Widener Programming Team traveled from Chester, PA to Worcester, MA, to compete in the regional programming contest. The team traveled on THREE different types of roads, RURAL, URBAN, and HIGHWAY, with different speed limits. Write a program that asks user to enter the number of hours team traveled on each type of roads and the travel speed for each type. The program calculates the total distance the team traveled and the average speed. Use the following formulas: DISTANCE = SPEED*TIME, SPEED = DISTANCE/TIME

Use the following example to test your program: team traveled 2.5 hours with speed 65 MPH (miles per hour), 1.5 hours with speed 55 MPH and 1.5 hours with speed 35 MPH. The total distance is:
2.5*65+1.5*55+1.5*35= 297.5 miles.
The average speed is: 297.5/5.5 = 54.09 MPH