Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2.1, Problem 4STE
Give a C++ statement that will increase the value of the variable length by 8.3. The variable length is of type double.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C++ statement that declares a named constant PI of double type with a value of 3.14.
Please code using C++ and only use the header <iostream>. The use of any other headers will not be accepted. Thank you.
C++ I am missing something in my code or have it completely wrong
Declare a Boolean variable named validPassword. Use validPassword to output "Valid" if passPhrase contains no more than 4 digits and passPhrase's length is greater than 4, and "Invalid" otherwise.
Ex: If the input is J8769, then the output is:
Valid
Ex: If the input is xkSr, then the output is:
Invalid
Note: isdigit() returns true if a character is a digit, and false otherwise. Ex: isdigit('8') returns true. isdigit('a') false.
#include <iostream>using namespace std;
int main() { string passPhrase; cin >> validPassword; for (int i = 0; i < validPassword.length(); i++) { cin >> passPhrase; if (isdigit(passPhrase.at(i))) hasDigit = true } if (validPassword) { cout << "Valid" << endl; } else { cout << "Invalid" << endl; } return 0;}
Chapter 2 Solutions
Problem Solving with C++ (10th Edition)
Ch. 2.1 - Give the declaration for two variables called feet...Ch. 2.1 - Give the declaration for two variables called...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Give a C++ statement that will increase the value...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Prob. 6STECh. 2.1 - Prob. 7STECh. 2.2 - Give an output statement that will produce the...Ch. 2.2 - Give an input statement that will fill the...Ch. 2.2 - Prob. 10STE
Ch. 2.2 - Write a complete C++ program that writes the...Ch. 2.2 - Write a complete C++ program that reads in two...Ch. 2.2 - Prob. 13STECh. 2.2 - Write a short program that declares and...Ch. 2.3 - Convert each of the following mathematical...Ch. 2.3 - Prob. 16STECh. 2.3 - What is the output of the following program lines...Ch. 2.3 - Write a complete C++ program that reads two whole...Ch. 2.3 - Given the following fragment that purports to...Ch. 2.3 - What is the output of the following program lines...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Suppose savings and expenses are variables of type...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Consider a quadratic expression, say x2 x 2...Ch. 2.4 - Consider the quadratic expression x2 4x + 3...Ch. 2.4 - What is the output of the following cout...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What output would be produced in the previous...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the most important difference between a...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - Write a complete C++ program that outputs the...Ch. 2.5 - The following if-else statement will compile and...Ch. 2.5 - Prob. 36STECh. 2.5 - Write a complete C++ program that asks the user...Ch. 2 - A metric ton is 35,273.92 ounces. Write a program...Ch. 2 - The Babylonian algorithm to compute the square...Ch. 2 - Many treadmills output the speed of the treadmill...Ch. 2 - Write a program that plays the game of Mad Lib....Ch. 2 - The following is a short program that computes the...Ch. 2 - A government research lab has concluded that an...Ch. 2 - Workers at a particular company have won a 7.6%...Ch. 2 - Modify your program from Programming Project 2 so...Ch. 2 - Negotiating a consumer loan is not always...Ch. 2 - Write a program that determines whether a meeting...Ch. 2 - Prob. 6PPCh. 2 - It is difficult to make a budget that spans...Ch. 2 - You have just purchased a stereo system that cost...Ch. 2 - Write a program that reads in ten whole numbers...Ch. 2 - Modify your program from Programming Project 9 so...Ch. 2 - Sound travels through air as a result of...Ch. 2 - Prob. 12PPCh. 2 - The HarrisBenedict equation estimates the number...Ch. 2 - Write a program that calculates the total grade...Ch. 2 - It is important to consider the effect of thermal...Ch. 2 - Prob. 16PP
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 a C++ program to calculate a rectangle's area. The program consists of the following function: getLength – This function should ask the user to enter the rectangle's length, and then returns that value as a double getWidth – This function should ask the user to enter the rectangle's width, and then returns that value as a double. getArea – This function should accept the rectangle's length and width as arguments and return the rectangle's area. • displayData – This function should accept the rectangle's length, width and area as arguments, and display them in an appropriate message on the screen. main – This function consists of calls to the above functions.arrow_forwardQ.3) Write a C++ code that can draw the following pattern 100 times.arrow_forwardQ3:-Write a program in C++ that finds The following equation (Note : Taking into consideration the priority) Z-pr % q + w/x - y* zarrow_forward
- write the code in c++arrow_forwardThere are a total of 30 chickens and rabbits in a coop. The total number of feet of chickens and rabbits is 96. Accordingly, write the C ++ code that calculates how many rabbits and chickens there are in the coop.arrow_forwardQ3: Write a program of c++ that prints the day number of the year, given the date in the form month-day-year. For example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. The program should check for a leap year. A year is a leap year if it is divisible by 4, but not divisible by 100. For example, 1992 and 2008 are divisible by 4, but not by 100. A year that is divisible by 100 is a leap year if it is also divisible by 400. For example, 1600 and 2000 are divisible by 400. However, 1800 is not a leap year because 1800 is not divisible by 400.arrow_forward
- write a c++ programe :do it by flag Ask user to enter an integer and then determine whether it is even or odd? make a boolean variable that we call it flag. initially the flag is initilized by false or zero. if user enter a number that the remainder of devision of that number by 2 is zero, then you change the value of flag from 0 or false to 1 or true. then by if statement, you check the flag, if the flag is equal to true then you say: "an integer you entered is even", otherwise you enter: "an integer you entered is odd".arrow_forwardIn c++ you have 5 different countries, Each country contains two different integers. Example England(30, 10) in that format, how will you calculate and find the country with the smallest integers between those 5 countries and also calculate and display the total steps that country has compared to the other countries. Example…England has 50 steps.arrow_forwardWe have 100 critics who have rated the top movie of the year: Enchantio! Write a C++ program that lists the ratings. If there are three ratings in a row over 80, Enchantio wins an Oscar! (X/40) Print the following: The 100 ratings Enchantio receives from the critics The number of awards Enchantio won The maximum rating Enchantio receivedarrow_forward
- Write in c++ pleasearrow_forwardWrite a C++ program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getScore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of the five scores to be entered. void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. **DO NOT USE AN ARRAY OR GLOBAL VARIABLES!!!*** YOU MUST USE THE STATED FUNCTIONS. AND INPUT VALIDATION. For FULL CREDIT DISPLAY THE LOWEST SCORE WITH GOOD OUTPUT DESCRIPTION you MUST USE function prototyping.. DO NOT ACCEPT SCORES LESS THAN 0 OR GREATER THAN…arrow_forwardWrite a program in C++ that: Declares a variable suitable for holding a person’s name Prompts the user to enter a person’s name with the text Enter name: Reads the user's input and stores it in the variable created in step 1 Outputs the following information about the name they entereda. The index of the first character of the last nameb. The first 3 characters of the first namec. The last 3 characters of the last nameYour output should look like the examples below. **Note: Your code should account for the fact that the user might enter a middle name or initial. Example 1: Enter name: Grace Hopper Index of the first character of the last name: 6 First 3 characters of the first name: Gra Last 3 characters of the last name: per Example 2: Enter name: Dorothy J. Vaughan Index of the first character of the last name: 11 First 3 characters of the first name: Dor Last 3 characters of the last name: hanarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Algebraic Expressions – Algebra Basics; Author: TabletClass Math;https://www.youtube.com/watch?v=U-7nq7OG18s;License: Standard YouTube License, CC-BY
Python Tutorial for Beginners 3 - Basic Math, Mathematical Operators and Python Expressions; Author: ProgrammingKnowledge;https://www.youtube.com/watch?v=Os4gZUI1ZlM;License: Standard Youtube License