Docsity

Algorithm Design and Programming Exercises: Weighted Average and Variable Manipulation, Exercises of Programming Languages

Toggle sidebar
bg1
Design an algorithm to find the weighted average of four test scores. The four test scores and
their respective weights are given in the following format:
test score 30, 25, 20, 25
weightTestScore 35% , 25% , 15% , 25%
โ— Step1. Read the score of each test
โ— Step2. Read the weight of each test
โ— Step3. Multiply each test score by its respective weight (testscore1 * weight1).
โ— Step4. Get the of the results you got in step 3 ((testscore1 * weight1) +(testscore2 *
weight2) etc)
โ— Step5. Divide the sum you calculated in step three by 4 ( the number of tests)
Suppose that x, y, z, and w are int variables. What is stored in x, y, z, and w after the
following statements execute?
x = 9;
y = x - 4;
z = (y + 7) % 6;
w = (x * z) / y - 3;
z = w + (x - y + 2) % x;
โ— x=9
โ— y=5
โ— z=7
โ— w=0

Partial preview of the text

Download Algorithm Design and Programming Exercises: Weighted Average and Variable Manipulation and more Exercises Programming Languages in PDF only on Docsity!

Design an algorithm to find the weighted average of four test scores. The four test scores and their respective weights are given in the following format: test score 30, 25, 20, 25 weightTestScore 35% , 25% , 15% , 25% โ— Step1. Read the score of each test โ— Step2. Read the weight of each test โ— Step3. Multiply each test score by its respective weight (testscore1 * weight1). โ— Step4. Get the of the results you got in step 3 ((testscore1 * weight1) +(testscore2 * weight2) etc) โ— Step5. Divide the sum you calculated in step three by 4 ( the number of tests) Suppose that x, y, z, and w are int variables. What is stored in x, y, z, and w after the following statements execute? x = 9; y = x - 4; z = (y + 7) % 6; w = (x * z) / y - 3; z = w + (x - y + 2) % x; โ— x= โ— y= โ— z= โ— w=