Starting Out with Programming Logic and Design (4th Edition)
4th Edition
ISBN: 9780133985078
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 3AW
Write assignment statements that perform the following operations with the variables a and b.
- a. Adds 2 to a and stores the result in b
- b. Multiplies b times 4 and stores the result in a
- c. Divides a by 3.14 and stores the result in b
- d. Subtracts 8 from band stores the result in a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write assignment statements that perform the following operations with the variables a and b (Python)A. Adds 2 to a and stores the result in bB. Multiplies b times 4 and stores the result in aC. Divides a by 3.14 and stores the result in bD. Subtracts 8 from b and stores the result in a
True or False To increment a variable means to increase its value and to decrement a variable means to decrease its value.
Looping Construct with Floating Point Numbers
Write a program that utilizes a while-loop to read a set of five floating-point values from user
input. Include code to prevent an endless loop. Ask the user to enter the values, then print the
following data:
Total
Average
Maximum
Minimum
Interest on total at 20%
Answer:
Chapter 2 Solutions
Starting Out with Programming Logic and Design (4th Edition)
Ch. 2.1 - Who is a programmers customer?Ch. 2.1 - What is a software requirement?Ch. 2.1 - What is an algorithm?Ch. 2.1 - What is pseudocode?Ch. 2.1 - Prob. 2.5CPCh. 2.1 - Prob. 2.6CPCh. 2.2 - Prob. 2.7CPCh. 2.2 - Prob. 2.8CPCh. 2.2 - What is a sequence structure?Ch. 2.2 - Prob. 2.10CP
Ch. 2.2 - Prob. 2.11CPCh. 2.2 - Prob. 2.12CPCh. 2.2 - Summarize three common rules for naming variables.Ch. 2.2 - Prob. 2.14CPCh. 2.2 - Look at the following pseudocode statement: Input...Ch. 2.2 - Prob. 2.16CPCh. 2.2 - Prob. 2.17CPCh. 2.2 - What two steps usually take place when a program...Ch. 2.2 - What does the term user-friendly mean?Ch. 2.3 - Prob. 2.20CPCh. 2.3 - When you assign a value to a variable, what...Ch. 2.3 - Summarize the mathematical order of operations, as...Ch. 2.3 - Prob. 2.23CPCh. 2.3 - Prob. 2.24CPCh. 2.4 - What two items do you usually specify with a...Ch. 2.4 - Does it matter where you write the variable...Ch. 2.4 - What is variable initialization?Ch. 2.4 - Prob. 2.28CPCh. 2.4 - What is an uninitialized variable?Ch. 2.7 - Prob. 2.30CPCh. 2.7 - Prob. 2.31CPCh. 2.7 - Prob. 2.32CPCh. 2 - A error does not prevent the program from running,...Ch. 2 - Prob. 2MCCh. 2 - A(n) _______ is a set of well-defined logical...Ch. 2 - An informal language that has no syntax rules, and...Ch. 2 - A ____ is a diagram that graphically depicts the...Ch. 2 - Prob. 6MCCh. 2 - Prob. 7MCCh. 2 - Prob. 8MCCh. 2 - Prob. 9MCCh. 2 - A(n) _____ is a message that tells (or asks) the...Ch. 2 - A(n) ________ sets a variable to a specified...Ch. 2 - In the expression 12 + 7, the values on the right...Ch. 2 - A(n) _____ operator raises a number to a power. a....Ch. 2 - A(n) _________ operator performs division, but...Ch. 2 - A(n) ____ specifies a variable's name and data...Ch. 2 - Assigning a value to a variable in a declaration...Ch. 2 - Prob. 17MCCh. 2 - Prob. 18MCCh. 2 - A debugging process in which you imagine that you...Ch. 2 - Prob. 20MCCh. 2 - Programmers must be careful not to make syntax...Ch. 2 - In a math expression, multiplication and division...Ch. 2 - Variable names can have spaces in them.Ch. 2 - In most languages, the first character of a...Ch. 2 - Prob. 5TFCh. 2 - In languages that require variable declarations, a...Ch. 2 - Uninitialized variables are a common cause of...Ch. 2 - The value of a named constant cannot be changed...Ch. 2 - Hand tracing is the process of translating a...Ch. 2 - Prob. 10TFCh. 2 - What does a professional programmer usually do...Ch. 2 - What is pseudocode?Ch. 2 - Computer programs typically perform what three...Ch. 2 - What does the term user-friendly mean?Ch. 2 - What two things must you normally specify in a...Ch. 2 - What value is stored in uninitialized variables?Ch. 2 - Design an algorithm that prompts the user to enter...Ch. 2 - Design an algorithm that prompts the user to enter...Ch. 2 - Write assignment statements that perform the...Ch. 2 - Assume the variables result, x, y, and z are all...Ch. 2 - Write a pseudocode statement that declares the...Ch. 2 - Write a pseudocode statement that declares the...Ch. 2 - Write a pseudocode statement that assigns the...Ch. 2 - Write a pseudocode statement that assigns the sum...Ch. 2 - Write a pseudocode statement that subtracts the...Ch. 2 - Write a pseudocode statement that multiplies the...Ch. 2 - If the following pseudocode were an actual...Ch. 2 - Prob. 12AWCh. 2 - If the following pseudocode were an actual...Ch. 2 - If the programmer translates the following...Ch. 2 - The following code will not display the results...Ch. 2 - Find the error in the following pseudocode....Ch. 2 - Find the error in the following pseudocode....Ch. 2 - Find the error in the following pseudocode....Ch. 2 - Find the error in the following pseudocode....Ch. 2 - Personal Information Design a program that...Ch. 2 - Sales Prediction A company has determined that its...Ch. 2 - Land Calculation One acre of land is equivalent to...Ch. 2 - Total Purchase A customer in a store is purchasing...Ch. 2 - Distance Traveled Assuming there are no accidents...Ch. 2 - Sales Tax Design a program that will ask the user...Ch. 2 - Miles-per-Gallon A cars miles-per-gallon (MPG) can...Ch. 2 - Tip, Tax, and Total Design a program that...Ch. 2 - Celsius to Fahrenheit Temperature Converter Design...Ch. 2 - Stock Transaction Program Last month Joe purchased...Ch. 2 - Cookie Calories A bag of cookies holds 40 cookies....Ch. 2 - Male and Female Percentages Design a program that...Ch. 2 - Ingredient Adjuster A cookie recipe calls for the...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write assignment statements that perform the following operations with the variablesa, b, and c .A) Adds 2 to a and stores the result in b .B) Multiplies b times 4 and stores the result in a .C) Divides a by 3.14 and stores the result in b .D) Subtracts 8 from b and stores the result in a .E) Stores the value 27 in a.F) Stores the character ‘K’ in c .G) Stores the ASCII code for ‘B’ in c .arrow_forwardJava program | nested looparrow_forwardQ7-Write a program that simulates a simple calculator. It reads two integers and a character. If the character is a +, the sum is printed; if it is a -, the difference is printed; if it is a *, the product is printed; if it is a /, the quotient is printed; and if it is a %, the remainder is printed. (Use a switch statement.)arrow_forward
- All programming languages have a loop capability. Looping is the program logic’s ability to repeat one or more lines of code either: A set number of times, a “for loop” (i.e. 10, 100, 500, 763 or more times) An “unknown” number of times (i.e. loop terminates if a tested condition becomes “true” or as long as the tested condition remains “false”), a “while” loop, a “do until” loop, a “do while” loop. This Lab exercise demonstrates the use of the “For Loop”, a standard loop in all programming languages. C++ standard For Loop format looks like: For (n = 1; n <= 100; n++) { Loop line 1 code; Loop line 2 code; Loop line 3 code; Loop line N code; } The loop code needs: A “loop counter variable” (n in the above example) to keep track of how many iterations this loop has run A starting value (i.e. 1 in the above example) A stop test (i.e. run as…arrow_forwardBasic while loop expression. Write a while loop that prints userNum divided by 4 (integer division) until reaching 2 or less. Follow each number by a space. Example output for userNum = 160:40 10 2 Note: These activities may test code with different test values. This activity will perform four tests, with userNum = 160, then with userNum = 8, then with userNum = 0, then with userNum = -1. See "How to Use zyBooks".Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.arrow_forwardStandard Voltage Classification The Philippine Grid Code and Philippine Distribution Code define the following voltage levels: Low Voltage: a voltage level not exceeding 1kV Medium Voltage: exceeding 1 kV up to 34.5 kv High Voltage: exceeding 34.5 kV up to 230 kV Extra High Voltage: exceeding 230 kV up to 765 kv Ultra High Voltage: exceeding 765 kV (assumed) Make a Matlab program that will ask the user to input a voltage value in kV and the program will classify it according to the standard voltage classification Sample Output: >>voltlvl Input a voltage value in kV: 138 138 kV is a high voltage levelarrow_forward
- Problem Description: A while loop and do/while loop will repeat code while the condition is true. The basic difference is when the condition is checked. The while loop checks the condition before the loop starts or after the loop ends. A do/while loop will check the condition at the end of the loop to determine if the loop should be repeated. A do/while loop will run at least once whereas a while may be skipped entirely. while ( ) do I/ Repeated code goes here I/ Repeated code goes here while ( ); Checkpoint 1: Use a while loop to display the numbers 1 through 10. You must initialize your loop counter before the loop and increment the loop counter inside the loop. Checkpoint 2: Use a while to ask the user for a list of numbers. It is not known how many numbers the user will enter, but the last number will be -1. After all numbers have been entered, state how many numbers were put in. Checkpoint 3: Use a do/while loop to display the numbers I through 10. You must initialize your loop…arrow_forwardWrite assignment statements that perform the following operations with the variables a, b, and c.1. Adds 2 to a and stores the result in b2. Multiplies b times 4 and stores the result in a3. Divides a by 3.14 and stores the result in b4. Subtracts 8 from b and stores the result in a5. Stores the character ‘K’ in c6. Stores the Unicode code for ‘B’ in carrow_forwardInstructions The program in the Programming Example: Fibonacci Number does not check: Whether the first number entered by the user is less than or equal to the second number and whether both the numbers are nonnegative. Whether the user entered a valid value for the position of the desired number in the Fibonacci sequence. Rewrite that program so that it checks for these things. NOTES: If an invalid number is entered for case 1 above, prompt the user to enter both numbers again. If an invalid number is entered for case 2, prompt the user to enter a value until a valid value is entered. the code: #include <iostream> using namespace std; int main() { //Declare variables int previous1; int previous2; int current; int counter; int nthFibonacci; cout << "Enter the first two Fibonacci numbers: "; //Step 1 cin >> previous1 >> previous2; //Step 2 cout << endl; //verify the first two values if(previous1<0 && previous2>0)…arrow_forward
- C++ Programming: Instructions The program in Example 5-6 implements the Number Guessing Game. However, in that program, the user is given as many tries as needed to guess the correct number. Rewrite the program so that the user has no more than five tries to guess the correct number. Your program should print an appropriate message, such as “You win!” or “You lose!”. Code Given: //Flag-controlled while loop. //Number guessing game. #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int num; //variable to store the random number int guess; //variable to store the number guessed by the user bool isGuessed; //boolean variable to control the loop srand(time(0)); num = rand() % 100; isGuessed = false; while (!isGuessed) { cout << "Enter an integer greater" <<" than or equal to 0 and " <<"less than 100: "; cin >> guess; cout << endl; if (guess == num) { cout << "You win! " <<…arrow_forwardIdentifying Triangles allowed language: C Languange The output and input should be the same as the samples.arrow_forward5- Find the error in the following code. x=-10:1:10; y=-10:2:10; plot(x,y) O Plot is not available in MATLAB O Syntax of plot is wrong O Length of x and y should be same O No errorarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
.2: Function Parameters and Arguments - p5.js Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=zkc417YapfE;License: Standard Youtube License