Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 1.4, Problem 27STE
Suppose you write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
. Write a program that generates and prints 50 random integers, each between 3 and 6.
.Write a program that generates a random number, x, between 1 and 50, a random number y
between 2 and 5, and computes x".
.Write a program that generates a random number between 1 and 10 and prints your name
that many times.
.Write a program that generates a random decimal number between 1 and 10 with two decimal
places of accuracy. Examples are 1.23, 3.45, 9.80, and 5.00.
f.
A laborant in a laboratory does a number of antigen tests in one day. Write a program that
simulates the number of antigen tests done in a day in a laboratory, displays the number of
positives and negatives, and calculates the % of positives in one day. Your program needs
to first generate a random number that will show the number of tests done in a day. One
laboratory in a day cannot do more than 100 tests and less than 1 (they do at least one).
Then for each of the tests, your program needs to generate a random number to show
whether they are positive or negative. In order to write this program, you need to have the
following three functions used by the main function:
test result (void): This function generates a test result. It should randomly
return either one or zero. 1 means positive test result and 0 means negative test result.
float positive percentage (int,int) : This function takes the total number of
positives and the total number of tests and returns the % of positives.…
Help me answer to question 4.all question is relate thanks.
1. Write a program to iteratively compute Fibonacci numbers (named after an Italian mathematician).Some Fibonacci numbers are 1, 1, 2, 3, 5, 8, ... where the next number is found by summing the preceding two numbers. Your program will read in a number, like 7, report the first 7 numbers. in this case1,1,2,3,5,8,13. Your program is not assured of receiving good data, thus if -2 is received as the number of numbers, then an error should be reported.
2. Assume that an input string consists of a string of 32 0’s and 1’s representing a binary number.
a) Write a program that will convert this binary integer to its base 10 representation.
b) Given a string representation of an integer in base 10 convert this integer to its binary representation. The output should consist of a string of 32 0’s and 1’s representing the binary number.
3. You are working for a software firm that is to develop a word processor. In order to create an…
Chapter 1 Solutions
Problem Solving with C++ (10th Edition)
Ch. 1.1 - Prob. 1STECh. 1.1 - What would be the data for a program to add two...Ch. 1.1 - Prob. 3STECh. 1.1 - What is the difference between a machine-language...Ch. 1.1 - What is the role of a compiler?Ch. 1.1 - What is a source program? What is an object...Ch. 1.1 - What is an operating system?Ch. 1.1 - What purpose does the operating system serve?Ch. 1.1 - Prob. 9STECh. 1.1 - Prob. 10STE
Ch. 1.1 - Prob. 11STECh. 1.2 - An algorithm is approximately the same thing as a...Ch. 1.2 - Prob. 13STECh. 1.2 - Prob. 14STECh. 1.2 - Prob. 15STECh. 1.3 - If the following statement were used in a C++...Ch. 1.3 - What is the meaning of \n as used in the following...Ch. 1.3 - What is the meaning of the following statement...Ch. 1.3 - What is the meaning of the following statement...Ch. 1.3 - What is the meaning of this directive? # include...Ch. 1.3 - What, if anything, is wrong with the following...Ch. 1.4 - Prob. 22STECh. 1.4 - Prob. 23STECh. 1.4 - If you omit a punctuation symbol (such as a...Ch. 1.4 - Omitting the final brace } from a program produces...Ch. 1.4 - Prob. 26STECh. 1.4 - Suppose you write a program that is supposed to...Ch. 1 - Using your text editor, enter (that is, type in)...Ch. 1 - Modify the C++ program you entered in Practice...Ch. 1 - Further modify the C++ program that you already...Ch. 1 - Modify the C++ program that you entered in...Ch. 1 - Modify the C++ program that you entered in...Ch. 1 - Prob. 6PCh. 1 - Write a C++ program that reads in two integers and...Ch. 1 - Write a program that prints out C S ! in large...Ch. 1 - Write a program that allows the user to enter a...Ch. 1 - Write a program that allows the user to enter a...Ch. 1 - Write a program that inputs a character from the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the difference between the names defined in an ML let construct from the variables declared in a C bloc...
Concepts of Programming Languages (11th Edition)
File Previewer Write a program that asks the user for the name of a text file. The program should display the f...
Starting Out with C++: Early Objects
Identity the termination condition in each of the following iterative statements. a. while (Count 5): . . . b....
Computer Science: An Overview (12th Edition)
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
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
- An instructor gives a series of exams during the semester in her math class. At the end of the semester she drops each student's lowest test score before averaging the scores. She has asked you to design a program that will read a student's test scores as input and calculate the average with the lowest score dropped. Here is the algorithm that you developed: Get the student's test scores. Calculate the total of the scores. Find the lowest score. Subtract the lowest score from the total. This gives the adjusted total. Divide the adjusted total by 1 less than the number of test scores. This is the adjusted average. Display the average. The test scores are in a text file named scores.txt and contains the following: Mickey, 71.0, 42.0, 83.0 Donald, 94.0, 73.0, 72.0, 81.0 Minnie, 95.0, 85.0, 45.0, 55.0, 65.0 A sample run is as follows: Enter a file containing floating point numbers: scores.txt Test scores for Mickey: ['71.0', '42.0', '83.0'] Removed the lowest score of 42.0 for Mickey The…arrow_forwardWrite a program that determines the hamming distance of two DNA strands. Your program should do the following: 1. prompt the user for 2 DNA strands 2. Making use of problem 4, check if the strands are valid. If the inputted strands are of different lengths, this is considered invalid input. If one or both of the strands are invalid, the program ends. 3. Iterate over the two DNA strands and sum the number of differences. 4. Output the hamming distance Example: Enter a DNA strand: AATG Enter a second DNA strand: AATC The hamming distance of AATG and AATC is 1 Enter a DNA strand: AATG Enter a second DNA strand: T Invalid input Enter a DNA strand: ABC Enter a second DNA strand: AATG Invalid input Enter a DNA strand: AATG Enter a second DNA strand: TTAC The hamming distance of AATG and TTAC is 4 Note: the hamming distance is the number of differences / differing characters in two strings. Examples: ● ‘AATG’ and ‘AATC’ have a hamming distance of 1 because only the last character…arrow_forwardWrite a program in python that determines the hamming distance of two DNA strands. Your program should do the following: 1. prompt the user for 2 DNA strands 2. Making use of problem 4, check if the strands are valid. If the inputted strands are of different lengths, this is considered invalid input. If one or both of the strands are invalid, the program ends. 3. Iterate over the two DNA strands and sum the number of differences. 4. Output the hamming distance Example: Enter a DNA strand: AATG Enter a second DNA strand: AATC The hamming distance of AATG and AATC is 1 Enter a DNA strand: AATG Enter a second DNA strand: T Invalid input Enter a DNA strand: ABC Enter a second DNA strand: AATG Invalid input Enter a DNA strand: AATG Enter a second DNA strand: TTAC The hamming distance of AATG and TTAC is 4 Note: the hamming distance is the number of differences / differing characters in two strings. Examples: ● ‘AATG’ and ‘AATC’ have a hamming distance of 1 because only the last…arrow_forward
- Write an LMC(little man computer) program that calculates the square value of an input number. The program gets the input number from the In-Basket, calculates the square value of the input number, and sends the square value to the Out-Basket. You may assume anything that can help you write the program correctly.arrow_forwardSometimes we write similar letters to different people. For example, you might write to your parents to tell them about your classes and your friends and to ask for money; you might write to a friend about your love life, your classes, and your hobbies; and you might write to your brother about your hobbies and your friends and to ask for money. Write a program that prints similar letters such as these to three people of your choice. Each letter should have at least one paragraph in common with each of the other letters. Your main program should have three method calls, one for each of the people to whom you are writing. Try to isolate repeated tasks into methods.arrow_forward. A palindrome is a number or text phrase that reads the same backwards or forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a python program that reads a 5 digit integer and determines whether it is a palindrome. Hint: One way to do this is to use division (/) and modulus (%) operators to separate the number into individual digits.arrow_forward
- Python Write a program that receives a number from a user and checks if it's float or integer.In case of being float, print for the user that his/her number is float with integer part andfractional part. In case of being integer, print to the user that his/her number is aninteger and odd/even numbeRarrow_forward(Program) Write a program to simulate the rolling of two dice. If the total of the two dice is 7 or 11, you win; otherwise, you lose. Embellish this program as much as you like with betting, different odds, different combinations for win or lose, stopping play when you have no money left or reach the house limit, displaying the dice, and so forth. (Hint: Calculate the dots showing on each die with theexpressiondots=(int)(6.0randomnumber+1), where random number is between 0 and 1.)arrow_forwardWrite a program to get an integer input from the user. If the input is 25, take the length and breadth from the user and calculate the area of rectangle. [ Area of rectangle = length * breadth ] If the input is 40, get the side from the user and calculate the area of square. [ Area of square = side * side ] If the input is 65, get the radius from the user and calculate the area of circle. [ Area of circle = 3.14*r*r] Otherwise Display " Enter number 25 or 40 or 65 ".arrow_forward
- Create a program which transforms the number of days to years, weeks and days. For example: 375 days = 1 year 1 week 3 days. Use the remainder of the bigger unit. ( in C language)arrow_forwardWrite C# a program that simulates rolling five die. Your program should count the number of rolls it takes to get 5 identical values on the dice (five 1s, five 2s, etc.). If you’ve ever played the game Yahtzee, then you are looking for a Yahtzee. Your program should output the values obtained in each run, and then stop when all five have the same value. You should then output the number of rolls it took to get the Yahtzee.arrow_forwardExercise 2: Write a Python program that reads from the user an integer n, displays the triangular number sequence up to the nh term (i.e. 1, 3, 6, 10, ..., calculated as "n(n+1)/2" where n is a nonzero positive number. Note that your program should display a suitable error message if n is entered as a zero or a negative number. nth term). The triangular of a number n is Triangular ======== 1 3 3 6 4 10 5 15 Figure 2- Sample Run for n=6arrow_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 PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Introduction to Operators in C; Author: Neso Academy;https://www.youtube.com/watch?v=50Pb27JoUrw;License: Standard YouTube License, CC-BY