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 (8th Edition)
- Implement programs involving the use of while, do..while and for loop statement. Objectives: Topics Covered: Implementing programs using loops. Description FRIDAY THE 13TH When will Friday the 13th occur in 1990? Write a program that will find all months in 1990 in which the 13th falls on a Friday. You need to know the following. 1. January 1, 1990 was on a Monday. 2. September, April, June, and November have thirty days, all the rest have 31 except for February which has 28 except in leap years when it has 29. 3. 1990 is not a leap year. Note: To make it fair for everyone, you may not use any built-in date functions from your computer language. Sample Output if Applicable Sample Run In 1990, Friday the 13th occurs in the months: APRILarrow_forwardRun and Compile the given program. Note:Some codes are incorrect and some operators are missing.arrow_forwardFind errors. Make it full code with explanation remember . Complete code I need with output.arrow_forward
- Fibonacci numbers are a sequence of integers, starting with 1, where the value of each number is the sum of the two previous numbers, e.g. 1, 1, 2, 3, 5, 8, etc. Write a function called fibonacci that takes a parameter, n, which contains an integer value, and have it return the nth Fibonacci number. (There are two ways to do this: one with recursion, and one without.)arrow_forwardAnalyze the following code and fill in the output. I got the answers wrongarrow_forwardWrite these in Pseudocode #1a – In pseudocode, write a call to a function that passes 1 Integer variable and 1 Integer array, and saves a Boolean value in return. #1b – In pseudocode, write the function that accepts 1 Integer and 1 Integer array and returns a Boolean. In the function, search the Integer array with a for-loop, and if the Integer parameter is found in the array, return false. If the Integer parameter is not found, return true. #2a – In pseudocode, write a call to a module that passes 1 Integer variable, 1 Real variable, 1 String constant, and 1 String literal as arguments. #2b – In pseudocode, write the module header that accepts 1 Integer, 1 Real, and 2 Strings as parameters. #3 – This pseudocode has multiple problems. Fix the calling statement and the definition below so that the routine accepts 3 grades as parameters and returns the average into a variable.…arrow_forward
- # Exercise 1. Implement the algorithm covered in lectures that determines if an integer n is prime. Your function should return True, if n is prime, and False otherwise. Your algorithm has to be effective for n ~ 1,000,000,000,000.def isPrime(n):arrow_forwardPlease complete the following Java program using the math.random function. USE THE Math.random() class. DO NOT use arrays, the Random function. (i.e keep the program simple using while loops, if/else, for loops, etc)arrow_forwardWhich of the following statements are correct? Iteration is always worse than recursion. Recursion uses more memory than an iterative approach. Recursion uses less memory than an iterative approach. O Iterative function is always easier to write than recursion.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning