10507 Given an integer variable i and a floating-point variable f, write a state
ID: 3542202 • Letter: 1
Question
10507
Given an integer variable i and a floating-point variable f, write a statement that writes both of their values to standard output in the following format: i=value -of-i f=value -of-f
Thus, if i has the value 25 and f has the value 12.34, the output would be:
i=25 f=12.34
But if i has the value 187 and f has the value 24.06, the output would be:
i=187 f=24.06
----------------------------------------------------
10591
Write a literal representing the true value .
----------------------------------------------------
10561
Write a conditional that assigns 10,000 to the variable bonus if the value of the variable goodsSold is greater than 500,000 .
----------------------------------------------------
Project 19: Class scores Write a program that calculates the total grade for N classroom exercises as a percentage. The user should input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total points possible) and output it as a percentage. sample input (in bold) and output (in italics) is shown below.
How many exercises to input? 3
Score received for exercise 1: 10
Total points possible for exercise 1: 10
Score received for exercise 2: 7
Total points possible for exercise 2: 12
Score received for exercise 3: 5
Total points possible for exercise 3: 8
Your total is 22 out of 30, or 73.33%.
Input Details: The input will consist of an initial integer (let's refer to it as N) followed by N pairs of integers , all responses to program prompts.
Output Details: The program uses the prompts and labels shown in the example above.
----------------------------------------------------
Project 12: Ancient square root algorithm. The Babylonian algorithm to compute the square root of a number n is as follows:
1. Make a guess at the answer (you can pick n/2 as your initial guess).
2. Compute r = n / guess
3. Set guess = (guess + r) / 2
4. Go back to step 2 for as many iterations as necessary.
The more that steps 2 and 3 are repeated, the closer guess
will become to the square root of n.
Write a program that inputs an integer for n, iterates through the Babylonian algorithm until guess is within 1% of the previous guess, and outputs the answer as a double .
Input Details: The input will consist of a single integer . It is prompted for by the string "Enter number to compute the square root of."
Output Details: The program prints the label "The estimate of the square root of X is" followed by the estimate of the square root, where X is the number read in whose square root is being estimated. All numerical values should be printed with exactly two digits past the decimal point.
Given an integer variable i and a floating-point variable f, write a statement that writes both of their values to standard output in the following format: i=value -of-i f=value -of-f Thus, if i has the value 25 and f has the value 12.34, the output would be: i=25 f=12.34 But if i has the value 187 and f has the value 24.06, the output would be: i=187 f=24.06 10591 Write a literal representing the true value . 10561 Write a conditional that assigns 10,000 to the variable bonus if the value of the variable goodsSold is greater than 500,000 . Project 19: Class scores Write a program that calculates the total grade for N classroom exercises as a percentage. The user should input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total points possible) and output it as a percentage. sample input (in bold) and output (in italics) is shown below. How many exercises to input? 3 Score received for exercise 1: 10 Total points possible for exercise 1: 10 Score received for exercise 2: 7 Total points possible for exercise 2: 12 Score received for exercise 3: 5 Total points possible for exercise 3: 8 Your total is 22 out of 30, or 73.33%. Input Details: The input will consist of an initial integer (let's refer to it as N) followed by N pairs of integers , all responses to program prompts. Output Details: The program uses the prompts and labels shown in the example above. Ancient square root algorithm. The Babylonian algorithm to compute the square root of a number n is as follows: Make a guess at the answer (you can pick n/2 as your initial guess). Compute r = n / guess Set guess = (guess + r) / 2 Go back to step 2 for as many iterations as necessary. The more that steps 2 and 3 are repeated, the closer guess will become to the square root of n. Write a program that inputs an integer for n, iterates through the Babylonian algorithm until guess is within 1% of the previous guess, and outputs the answer as a double . Input Details: The input will consist of a single integer . It is prompted for by the string "Enter number to compute the square root of." Output Details: The program prints the label "The estimate of the square root of X is" followed by the estimate of the square root, where X is the number read in whose square root is being estimated. All numerical values should be printed with exactly two digits past the decimal point.Explanation / Answer
Answer 1 to 4 is here. Solving 5th one.
1. cout <<"i="<<intValue<<" f="<<floatValue <<endl;
2. literal bool b = true;
3. if (goosSold > 500000){
bonus = 10000;
}
4. #include <iostream>
using namespace std;
int main()
{
int numberExer= 0, exerciseNumber =1, totalAchieved = 0, maxTotal = 0;
cout <<"How many exercises to input? ";
cin >> numberExer;
cout << endl;
for (int i = 0; i < numberExer; i++){
int scoreAchieved = 0, totalScore = 0;
cout << "Score received for exercise "<< exerciseNumber<<" ";
cin >> scoreAchieved;
totalAchieved +=scoreAchieved;
cout << endl << "Total points possible for exercise "<<exerciseNumber<<" ";
cin >> totalScore;
maxTotal += totalScore;
exerciseNumber++;
}
float percentage =((float)totalAchieved/maxTotal ) * 100;
cout <<endl<<"Your total is "<< totalAchieved <<" out of "<<maxTotal <<", or"<< percentage <<"%.";
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.