Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 5, Problem 3E
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a Python program that reads an integer representing a month of the year, and then print the name of the month. Your program must include validation and error handling code. Thus, if the user enters a value outside the range of 1-12; or characters that cannot be converted to an integer, your code must print the appropriate message and continue without crashing. (Hint: You may NOT USE any 'if' statements.)
(This is a better version of an exercise from Chapter 1.) A government research lab has concluded that an artificial sweetener commonly used in diet soda pop causes death in laboratory mice. A friend of yours is desperate to lose weight but cannot give up soda pop. Your friend wants to know how much diet soda pop it is pos- sible to drink without dying as a result. Write a program to supply the answer. The input to the program is the amount of artificial sweetener needed to kill a mouse, the weight of the mouse, and the desired weight of the dieter. Assume that dietsoda contains 1/10th of 1% artificial sweetener. Use a named constant for this fraction. You may want to express the percent as the double value 0.001.
Write a Python program that reads an integer representing a month of the year, andthen print the name of the month. Your program must include validation and errorhandling code. Thus, if the user enters a value outside the range of 1-12; or charactersthat cannot be converted to an integer, your code must print the appropriatemessage and continue without crashing. (Hint: You may NOT USE any 'if' statements.)Examples:# Input: -5 Output: Please enter a number between 1 and 12:# Input: gkl Output: Please enter numbers only# Input: 6 Output: June
Chapter 5 Solutions
Programming in C
Ch. 5 - Type in and run the 12 programs presented in this...Ch. 5 - Write a program that asks the user to type in two...Ch. 5 - Write a program that accepts two integer values...Ch. 5 - Write a program that acts as a simple printing...Ch. 5 - You developed Program 4.9 to reverse the digits of...Ch. 5 - Write a program that takes an integer keyed in...Ch. 5 - Program 5.10 has several inefficiencies. One...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction To Programming Using Visual Basic (11th Edition)
Big data Big data describes datasets with huge volumes that are beyond the ability of typical database manageme...
Management Information Systems: Managing The Digital Firm (16th Edition)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
With this type of binding, the Java Virtual Machine determines at runtime which method to call, depending on th...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
What is the current (or proper) designation for MIG welding? TIG welding? Heliarc welding?
Degarmo's Materials And Processes In Manufacturing
Which of the following identifier forms is most readable? Support your decision. SumOfSales sum_of_sales SUMOFS...
Concepts Of Programming Languages
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
- . 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_forwardPlease answer it in Python Offer a program that knows how to find the solution of the jackpot price game in a way effective. it's up to you to choose a number at random, and it's up to your program. to guess it. You must write him 'g' if the number he guessed is too large, 'p' if the number is too small and 'b' if he guessed the right number. The number of trials is not limited. The program should always be able to guess the right number fast enough Example 1: Think of a number and I'll try to guess! Ready? Press Enter... Hmm.. Is it 15? p Hmm.. Is it 35? g Hmm.. Is it 31? g Hmm.. Is it 24? g Hmm.. Is it 20? g Hmm.. Is it 19? g Hmm.. Is it 17? p Hmm.. Is it 18? b I won! Example 2: Think of a number and I'll try to guess! Ready? Press Enter... Hmm.. Is it 4? p Hmm.. Is it 69? g Hmm.. Is it 49? g Hmm.. Is it 7? p Hmm.. Is it 19? p Hmm.. Is it 38? g Hmm.. Is it 25? g Hmm.. Is it 20? b I won! Example 3: Think of a number and I'll try to guess! Ready? Press Enter... Hmm.. Is it 46? g Hmm..…arrow_forwardThe manager of Mama Calari’s Pizza Palace wants a program that calculates and displays the number of pizza slices into which a circular pizza can be divided. The manager will enter the radius of the entire pizza. For this exercise, use 14.13 as the area of a pizza slice, and use 3.14 as the value of pi. Desk-check your solution’s algorithm using 10 as the pizza’s radius; then desk-check it using 8. (Hint: For the first desk-check, the number of pizza slices should be a little over 22.)arrow_forward
- Write a program that takes an integer num between 1 and 99999, then computes the number of digits in num. If the number exceeds 99999 or is less than 1, the program must output "False" to the user, otherwise, the output can be "One", "Two", "Three", "Four", or "Five IMPORTANT NOTE - Do not add any cout statements except for the final answer as specified above. Do not add "Enter a number", "the number of digits is" or any similar prompts. Also note that the grader is case-sensitive; so "one" is wrong but "One" is correct. Do not add any unnecessary spaces I/O Program Input: An integer num between 1 and 99999 Program Output: A single line that only has the number of digits in num Sample Testcase 0: Input: 5 Output: One Sample Testcase 1: Input: 450 Output: Three Sample Testcase 2: Input: 1000220 Output: Falsearrow_forwardWrite 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. (Refrance C++)arrow_forwardCreate a program (using Java or Python) for converting binary numbers to decimal numbers, and conversely. [You can not use the conversion functions from the mathematical library.] Your program should do the following: Ask the user if they want a Binary number converted to Decimal number, a Decimal number converted to a Binary number, or to quit the program. Ask the user for the number, take the appropriate action and then print out the appropriate message.arrow_forward
- accept input from the user, compute the output via a mathematical formula, and print a result using reasonable formatting. • Prompt the user for the radius of the lake. Accept the radius from the user. You are guaranteed that this radius will be an integer. You will learn how to accept numbers as input very soon. • Print out the area of the half-circular lake. A sample run might look like this: Enter the radius of the lake in meters: 9 The area of the lake is 127.2348 m^2. Remember that the area of a circle is given by a = Tr tr. For purposes of this program, you may assume that T = 3.1416. (Hint: Make this a constant, and you only ever have to type it once...) Program successfully runs o If your program doesn't run, you get zero points but a chance to resubmit it. • Program prints out the right value o I will not penalize you for rounding errors. • Good formatting of input and output • Readable and well-formatted program code Write your program in IDLE 3; anything 3.7 or above should…arrow_forwardCan answer the task below?arrow_forwardWrite a program which reads two integers and prints out the sum, the difference and the product. Divide them too, printing your answer to two decimal places. Also print the remainder after the two numbers are divided. Introduce a test to ensure that when dividing the numbers, the second number is not zero. What are the integer types in C?arrow_forward
- How do I write my computer program that shows the current population at 78,000. And there are 365 days in a year. A baby born every 7 seconds, someone dies every 13 seconds and an one new immigrant every 45 seconds. Print the next 5 years populationarrow_forwardCan you use Python programming language to wirte this code? Thank you very much!arrow_forwardWrite a C# program to enter the radius of 100 random circles and calculate the area for each one and count how many circles have the integer part of the area an even number. (Hint: the radius is of type double)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY