Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 2 - Why my assignment is late (3 pts) Write a Java program that helps a

ID: 3872366 • Letter: Q

Question


Question 2 - Why my assignment is late (3 pts) Write a Java program that helps a student write the text to an email explaining to their professor why their assignment is late Your program should prompt the user to enter the following information. Note: String inputs are to be one word and the number input is to be stored in a variable of type double The first or last name of your instructor Your name A food A number between 37.0 and 40.0 "I couldn't do my homework because my computer has a virus and so do all my pencils and pens." An adjective A color An animal After the strings and double are input, they should be substituted into the story below and output as an email to your prof using a single System.out.println() statement to the console (See sample output in figure 1) Dear professor [Instructor name] I am sorry that I am unable to turn in my computer assignment at this time. First, I ate a rotten [food], which made me turn [colour] and extremely ill. I came down with a fever of [fever]. Next my [adjective] pet [animal] must have smelled the remains of the [food] on my USB key (which is where my program was stored) because he ate it. I am currently rewriting my programs and hope you will accept my assignment late. Sincerely, [student name] Here is a sample output screen. User input is marked by

Explanation / Answer

Create a file app.java and paste given code into it! Filename must be app.java

app.java

import java.util.Scanner;
public class app {
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Enter first or last name of your instructor!" );
String inst_name;
inst_name = scanner.nextLine();   
System.out.println("Enter you name!" );
String your_name = scanner.nextLine();   

System.out.println("Enter A food!" );
String food = scanner.nextLine();   

System.out.println("Enter a number between 37.0 to 40.0!" );
String temperature = scanner.nextLine();   

System.out.println("Enter an adjective!" );
String adjective = scanner.nextLine();

System.out.println("Enter a color!" );
String color = scanner.nextLine();

System.out.println("Enter an animal!" );
String animal = scanner.nextLine();
  
System.out.println("Dear professor " + inst_name + ",");
System.out.println("I am sorry that I am unable to turn in my computer assignment at this time. "
+ "First, I ate a rotten " + food + " which made me turn " + color + " and extreamely ill. "
+ "I came down with a fever of " + temperature + ". Next my " + adjective + " pet " + animal
+ " must have smelled the remains of the " + food + " on my USB key (Which is where my program was stored)"
+ "because he ate it. I am currenlty rewriting my programs and hope you will accept my assignment late." );
System.out.println("Sincerely, " + your_name);

}
  
}

Sample Output:

Enter first or last name of your instructor!
John
Enter you name!
Akash
Enter A food!
Lasania
Enter a number between 37.0 to 40.0!
38.0
Enter an adjective!
favourite
Enter a color!
red
Enter an animal!
dog
Dear professor John,
I am sorry that I am unable to turn in my computer assignment at this time.
First, I ate a rotten Lasania which made me turn red and extreamely ill.
I came down with a fever of 38.0. Next my favourite pet dog
must have smelled the remains of the Lasania on my USB key (Which is where my program was stored)because he ate it.
I am currenlty rewriting my programs and hope you will accept my assignment late.
Sincerely,
Akash

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote