Answer:
import java.util.Scanner;
public class HomeSales
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name = "";
double sale = 0.0;
System.out.print("Enter a salesperson's initial (D, E, or F ) ");
char initial = input.next().charAt(0);
initial = Character.toUpperCase(initial);
if(initial == 'D')
name = "Danielle";
else if(initial == 'E')
name = "Edward";
else if(initial == 'F')
name = "Francis";
else
System.out.println("Invalid initials entered!");
if(!name.equals("")){
System.out.print("Enter sale amount ");
sale = input.nextDouble();
System.out.println(name + " " + sale);
}
}
}
Step-by-step explanation:
*The code is in Java.
Initialize the name and sale
Ask the user to enter the initial
Convert initial to uppercase
Check the initial using if else statement and depending on the value, set the name. If a valid initial is entered, print an error.
If the name is not empty (This implies that a valid initial was entered), ask the user to enter the sale amount and print the name and sale amount