Concept explainers
Explanation of Solution
Program purpose:
Prompt the age and name of the user and covert the name into uppercase then display the age and name.
Runtime errors:
The runtime error is commonly referred to as “bug”. It occurs during the execution of the program. It represents the logic or arithmetic errors.
Error #1:
Prompting string value from the user is in wrong format.
Correct statement:
//prompt the user to enter the string value
name = keyboard.next();
Error #2:
Converting the “name” text to upper case is in wrong format.
Correct statement:
//prompt the user to enter the string value
String result = name.toUpperCase();
Corrected code:
//include the required file
import java.util.Scanner;
//definition of "Input" function
public class Input
{
//definition of main method
public static void main(String[] args)
{
//create an object for scanner
Scanner keyboard = new Scanner(System...
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
- Please convert Mutual Recursion to Java. See attached image. Thank you.arrow_forwardPlease answer quickly in pythonarrow_forwardWord Statistics: The second requirement change is to allow replacement of all occurrences of a given word to a given replacemWrite the code only in python language with the opeartion exactly and necessary comments to be added.arrow_forward
- PYTHON: This exercise is a variation on "instrumenting" the recursive Fibonacci program to better understand its behavior. Write a supporting method that counts how many times the fib function is called to compute fib (n) where n is a user input. Hint: To solve this problem, you need an accumulator variable whose value "persists" between calls to fib. You can do this by making the count an instance variable of an object. Create a FibCounter class with the following methods: _init_(self) Creates a new FibCounter, setting its count instance variable to 0. getCount(self) Returns the value of count. fib(self, n) Recursive function to compute the nth Fibonacci number. It increments the count each time it is called. resetCount(self) Sets the count back to 0.arrow_forwardfunction in Python called PassFail(), that returns the number of points required on the last exam in order to pass this class based on the first four exam points and the 55% exam standard mentioned in the syllabus. Note: there are a total of five exams. The first four exams are worth 100 points each. The fifth and last exam is worth 200 points.arrow_forwardcode in python please thank youarrow_forward
- [Python Language] Using loops of any kind, lists, or is not allowed. Angela loves reading books. She recently started reading an AI generated series called “Harry Trotter”. Angela is collecting books from the series at her nearest bookstore. Since the series is AI generated, the publishers have produced an infinite collection of the books where each book is identified by a unique integer. The bookstore has exactly one copy of each book. Angela wants to buy the books in the range [l,r], where l ≤ r. As an example, the range [−3,3] means that Angela wants to buy the books − 3, − 2, − 1, 0, 1, 2, and 3. Dan also loves the series (or maybe annoying Angela – who knows, really), and he manages to sneak into the bookstore very early to buy all of the books in the range [d,u], where d ≤ u. When Angela later visits, sadly she will not find those books there anymore. For example, if Angela tries to buy books [−2,3] and Dan has bought books [0,2], Angela would only receive books − 2, − 1,…arrow_forwardPython question please include all steps and screenshot of code. Also please provide a docstring, and comments throughout the code, and test the given examples below. Thanks. Implement function heads() that takes no input and simulates a sequence of coin flips.The simulation should continue as long as 'HEAD' is flipped. When the outcome of a flipis 'TAIL', the function should return the number of 'HEAD' flips made up to that point.For example, if the simulation results in outcomes 'HEAD', 'HEAD', 'HEAD', 'TAIL', thefunction should return 3. NOTE: Recall that random.choice(['HEAD', 'TAIL']) returns'HEAD' or 'TAIL' with equal probability.>>> heads()0 # TAIL is the outcome of the first coin flip>>> heads()2 # The coin flips were HEAD, HEAD, TAIL>>> heads()1 # The coin flips were HEAD, TAIL>>> heads()5 # The coin flips were HEAD, HEAD, HEAD, HEAD, HEAD, TAILarrow_forwardModify the guessing-game program of Section 3.5 so that the user thinks of a number that the computer must guess. The computer must make no more than the minimum number of guesses, and it must prevent the user from cheating by entering misleading hints. (Hint: Use the math.log function to compute the minimum number of guesses needed after the lower and upper bounds are entered.)arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning