1. A main function with the function calls to Getl and GetD. Declare any variabl
ID: 3596198 • Letter: 1
Question
1. A main function with the function calls to Getl and GetD. Declare any variables and assign values as needed 2. Include the function definitions described below. Declare any variables and assign values as needed 3. Add the function prototypes Function 1. Write a function definition called GetL that takes no arguments and returns a character uppercase, and return it. Function 2. Write a function definition called GetD that takes no arguments and returns a double. The function will prompt the user to enter a double, get a double, print the double onto the screen, add 25.5 to the amount of the double, and return it.Explanation / Answer
import java.util.Scanner;
class Main{
public static Scanner sc = new Scanner(System.in);
public static void main(String args[]){
System.out.println(GetL());
System.out.println(GetD());
}
public static char GetL(){
char c;
System.out.print("Enter a character:");
// read character from input
c = sc.next().charAt(0);
//convert to uppercase
c = Character.toUpperCase(c);
return c;
}
public static double GetD(){
double d;
System.out.print("Enter a double value:");
// read double from input
d = sc.nextDouble();
//print to screen
System.out.println("Double value:"+d);
//add 25.5 to double value
d += 25.5;
return d;
}
}
/*
sample output
Enter a character: a
A
Enter a double value: 10.5
Double value:10.5
36.0
*/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.