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

I need someone to correct my coding using the instructions below Task 1 In order

ID: 3786370 • Letter: I

Question

I need someone to correct my coding using the instructions below

Task 1 In order to use variables in Java they must first be declared and initialized. First we will look at primitive data types The syntax for declaration is this: int number; String greeting To give it value, use the assignment operator number 25 greeting Hello You can also declare and initialize in the same line: int number 25 String greeting Hello In the area indicated, declare and initialize: 1. A String called name and value "Luis" 2. A second String called answer with "Good day" 3. An int with name piecount and value 16 Note: When assigning Strings it is necessary to have the double quotes around the characters to be stored. Also note the information stored is really an address in memory, and not the characters in the double quotes. This will be covered in further detail in a later lesson. When the program is run, the output should be: As runner 16 passed you, Luis said Good day

Explanation / Answer

import java.util.Scanner;
public class Lab1d
{
public static void main(String[] args)
{
int pieCount=16;
String answer="Good day";
String name="Luis";
Scanner scan=new Scanner(System.in);
System.out.println("as runner"+piecount+"passed you"+name+"said"+answer);
System.out.println("you see a girl,what is her name?(type rose)");
String na=scan.nextline();
scan.nextLine();
System.out.println(does she want a pie?(type yes)");
String replay=scan.next();
scan.nextLine();
System.out.println("how many pies do you have?(type 5)");
int n=scan.nextInt();
scan.nextLine();
System.out.println(na);
System.out.println(replay);
System.out.println(n);
System.out.println();
System.out.println("you met"+name+"while walking down the street");
System.out.println("when asked if she wanted pie,she replied"+replay);
System.out.println("you currently have"+n+"so you decided to give her one");
}
}
here the scanner will skip the nextline after using the next(),nextint() functions in order to avoid introduce the nextlinefunction after reading these.