Do
Solution to Programming Project 4.8
bool containsDigit(int number, int digit);
If number contains digit, then the function should return true. Otherwise, the function should return false. Your program should use this function to find the closest numbers that can be entered on the keypad.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Management Information Systems: Managing The Digital Firm (16th Edition)
SURVEY OF OPERATING SYSTEMS
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Concepts Of Programming Languages
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- a. Write a function named countDigits that accepts a positive integer as its parameter and returns the number of digits in that number. For example, the number 8546587 has seven digits, so the call countDigits(8546587) should return 7. You may assume that the value passed to your method is non-negative. b. Write a program to input an integer n and call the above function in part a if n is positive, else give 'Value must be Positive' message. Inputting will stop when 0 is entered.arrow_forwardin c++pls i am doing it on replitarrow_forwardPython code Screenshot and output is mustarrow_forward
- A particular talent competition has 5 judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer’s final score is determined by dropping the highest and lowest score received, then averaging the 3 remaining scores. Write a program that uses these rules to calculate and display a contestant’s score. It should include the following functions: • void getJudgeData() should ask the user for a judge’s score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the 5 judges. • double calcScore() should calculate and return the average of the 3 scores that remain after dropping the highest and lowest scores the performer received. This function should be called just once by main and should be passed the 5 scores.Two additional functions, described below, should be called by calcScore, which uses the returned information to determine which of the scores to drop.•…arrow_forwardAny help would be greatly appreciated!! If you could attached screenshots of the code that would be very helpful!! Write code for the following: Write Python code that uses a loop to prompt the user for five floating point numbers and reports the sum of the floats when the loop ends. Write Python code that defines a void function named divide that takes two numbers as parameters and then prints the quotient accurate to 1 decimal place when the first parameter is divided by the second one. A file named txt is shown on the right. Write Python code that opens this file, reads only the first two lines, and prints “Penny is 19” Penny 19 Kenny 20 Benny 21 Jenny 20arrow_forwardThis is the second lab for the Unit 4 zyBooks materials. Coding hints: def lapstomiles(user_laps): return user_laps / 4.00 #Please note that one mile is equal to four laps … print(f'{num_miles:.2f}') #We are formatting the laps into two decimal places. One lap around a standard high-school running track is exactly 0.25 miles. Define a function named laps_to_miles that takes a number of laps as a parameter, and returns the number of miles. Then, write a main program that takes a number of laps as an input, calls function laps_to_miles() to calculate the number of miles, and outputs the number of miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print(f'{your_value:.2f}') Ex: If the input is: 7.6 the output is: 1.90 Ex: If the input is: 2.2 the output is: 0.55 The program must define and call the following function:def laps_to_miles(user_laps) # Define your function here if __name__ == '__main__': user_laps =…arrow_forward
- Write a function called createTriangle that takes in a positive 1nt value and a char value (either u or d to indicate the triangle should be drawn either up or down), and displays the triangle. You are welcome to make your program handle uppercase input as well, but this is not required for this lab. Make sure that you write the createTriangle function prototype in drawtriangle.hpp and its implementation in drawtriangle.cpp, then and call from it inside of main.cpp. You'll find that skeleton code has already been provided and you simply need to call the function. Sample output #1 Enter the triangle height: 4 Enter 'u' or 'd' to indicate up or down: u Sample output #2 Enter the triangle height: 5 Enter 'u' or 'd' to indicate up or down: d ....arrow_forwardWrite a function that asks the user for their birthday month and day and then the function should call a nested function to find out the person’s zodiac sign. Test your program with some user input. Aries: March 21 - April 19 Taurus: April 20 – May 20 Gemini: May 21- June 21 Cancer: June 22- July 22 Leo: July 23 – August 22 Virgo: August 23 – September 22 Libra: September 23 – October 23 Scorpio: October 24 – November 21 Sagittarius: November 22 – December 21 Capricorn: December 22 – January 19 Aquarius: January 20 – February 18 Pisces: February 19 – March 20arrow_forwardThe following formula can be used to determine the distance an object falls due to gravity in a specific time period: d = 1⁄2 gt2The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the time in seconds that the object has been falling. Write a function named fallingDistance that accepts an object’s falling time (in seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Write a program that demonstrates the function by calling it in a loop that passes the values 1 through 10 as arguments and displays the return value.arrow_forward
- This is in c++. All other answers online on chegg and bartleby are wrong, so please don't copy and paste those. Thank you.arrow_forwardHere is part of the code from the main function in a program: int n1, n2, n3 = 8; double answer; string name = "Homer", city; Assume function doSomething has a string parameter and that it returns an int. Which of these would be valid ways to call the function from ma Please check all that apply. Wrong answers subtract points. O city = doSomething (name): answer = sqrt (doSomething ("Bob")); n2 = doSomething ("Adele is great!"); O cout << doSomething (n1) << end%; cout < doSomething (name) ; n1 = doSomething (name): 口ロ 口ロ口arrow_forwardI can’t figure out how to do this code with the “define” function!! Ughhhharrow_forward
- 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