Concept explainers
Exercises 43-50 refer to the following
Write Number2
Suppose we want to precede the last statement in this program by a statement that displays the following message:
The result of the computation is:
Write me such a statement.
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Prelude to Programming
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Problem Solving with C++ (9th Edition)
Database Concepts (7th Edition)
Starting Out with Java: Early Objects (6th Edition)
Experiencing MIS
Artificial Intelligence: A Modern Approach
- 25. Repeat Programming Exercise 24, but the wire is to be bent in the form of a circle. In this case, the user specifies the length of the wire and the program outputs the radius and area of the circle. (You may assume that . Also declare it as a named constant.)arrow_forward(Statistics) This is the formula for the standard normal deviate, z, used in statistical applications: z=(X)/ X is a single value. refers to an average value. refers to a standard deviation. Using this formula, you need to write a program that calculates and displays the value of the standard normal deviate when X=85.3,=80,and=4. a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. d. Test the formula written for Exercise 7c, using the data given in the problem.arrow_forward15. Write a program to implement and test the algorithm that you designed for Exercise 15 of Chapter 1. (You may assume that the value of . In your program, declare a named constant PI to store this value.)arrow_forward
- (Modify) a. Modify the program you wrote for Exercise 7 to provide the mass of a person as an output, given his or her weight as an input to the program. Use your program to determine the mass of a person who weighs 140 lbf on Earth. b. Modify the program written for Exercise 7a to also output the person’s weight on Mars and the moon. The pull of gravity on Mars is 12.54ft/sec2=3.728m/s2,andonthemoonis5.33ft/sec2=1.625m/s2.arrow_forward(Computation) A magic square is a square of numbers with N rows and N columns, in which each integer value from 1 to (N * N) appears exactly once, and the sum of each column, each row, and each diagonal is the same value. For example, Figure 7.21 shows a magic square in which N=3, and the sum of the rows, columns, and diagonals is 15. Write a program that constructs and displays a magic square for a given odd number N. This is the algorithm:arrow_forward4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and fertilizer from a local nursery. The nursery carries different types of vegetable fertilizers in various bag sizes. When buying a particular fertilizer, they want to know the price of the fertilizer per pound and the cost of fertilizing per square foot. The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, and the area, in square feet, that can be covered by the bag. The program should output the desired result. However, the program contains logic errors. Find and correct the logic errors so that the program works properly. // Logic errors. #include #include using namespace std; int main() { double costs double area; double bagsize; cout > bagsize; cout > cost; cout > area; cout << endl; cout << "The cost of the fertilizer per pound is: $" << bagsize / cost << endl; cout << "The cost of fertilizing per square foot is: $" << area / cost << endl; return 0; }arrow_forward
- Write an algorithm, output, input and design a programarrow_forwardPROGRAM 6: Three Zero GameWrite an HLA program that reads a number. Then by subtracting off a three and tens, determine if that value ends in a zero or a three. Three such numbers in a row wins the game! Shown below are sample program dialogues to help you build your program. Gimme a number: 20It ends in zero!Keep going...Gimme a number: 53It ends in three!Keep going...Gimme a number: 41Sorry Charlie! You lose the game!Gimme a number: 50It ends in zero!Keep going...Gimme a number: 23It ends in three!Keep going...Gimme a number: 70It ends in zero!You Win The Game! Gimme a number: 51Sorry Charlie! You lose The Game!arrow_forwardJust the algorithm in pseudo-code.arrow_forward
- The Salary Program: Modify the program from the textbook (Program 1-1,see below) which reads the number of hours an employee works reads the pay rate per hour computes the pay for the employee. Add the following steps: a) Read an amount of bonus paid to the employee.b) Compute the total pay as pay plus bonus.c) Compute the tax at 30% of the total pay.d) Compute the net pay as total pay minus tax, and e) Print a report showing: total pay, tax deduction, and net pay. Algorithm: 1. Prompt the user for number of hours.2. Read the value for hours.3. Prompt the user for hourly rate.4. Read the hourly rate.5. Prompt the user for amount of bonus.6. Read the value for bonus.7. Compute the pay.8. Compute the totalPay by adding bonus to pay.9. Compute the tax deduction by multiplying 30% times totalPay.10. Compute the netPay by subtracting tax from totalPay.11. Neatly print and label the following: a. totalPay b. tax c. netPay Put your…arrow_forward10. The algorithm shown in Figure 1-13 should calculate and print the gross pay for five workers; however, some of the instructions are missing from the algorithm. Complete the algorithm. If an employee works more than 40 hours, he or she should receive time and one-half for the hours worked over 40. read the employee's name, hours worked, and pay rate calculate gross pay = hours worked times pay rate otherwise, do this: calculate regular pay = pay rate times 40 calculate overtime hours = hours worked minus 40 calculate overtime pay = calculate gross pay = end if print the employee's name and gross pay end repeatarrow_forwardQuestion 13 W Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case. In the program below, y is a positive integer (e.g., 1, 2, 3, ..). result REPEAT 3 TIMES REPEAT y TIMES result result 1 What is the value of result after running the program? A y+ 3 3y 3yarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr