Hello I am confused on how to do this following the task wil

Hello I am confused on how to do this, following the task will help solve the code but I dont understand

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 itis 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 Task 2 Now that we have functioning variables, it is time to declare a Scanner In the space indicated, type: Scanner scan new Scanner (System.in); The System in indicates the information will come in from the computer\'s keyboard. However, ifyou run the program now, it will generate an exception. The compiler will not allow you to create a Scanner unless you import the Java package. Thus, in the space indicated, type: import java.util. Scanner Now we can use scan to obtain user input. In the space indicated for Task 2.1, you will use assign an int to pieCount using the keyboard. Type: name scan next Line The nextLine method will prompt the program to wait for user input. The same will be done for answer in the space for 2.2. For 2.3, however, rather than nextLine you will use

Solution

Lab1d.java

import java.util.Scanner;


public class Lab1d {

  
   public static void main(String[] args) {
       int pieCount = 16;
       String answer = \"Good day\";
       String name = \"Luis\";
      
       System.out.println(\"After runner \"+pieCount+\" passed you, \"+name+\" said \"+answer);
      
       Scanner scan = new Scanner(System.in);
       System.out.println(\"You see a girl, what is her name? (Type Rose) \");
       name = scan.next();
       System.out.println(\"Does she wants a pie? (Type yes)\");
       String replay = scan.next();
       System.out.println(\"How many pies do you have? (Type 5)\");
       int n = scan.nextInt();
       System.out.println(name);
       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\");
   }

}

Output:

After runner 16 passed you, Luis said Good day
You see a girl, what is her name? (Type Rose)
Rose
Does she wants a pie? (Type yes)
yes
How many pies do you have? (Type 5)
5
Rose
yes
5

You met Rose while walking down the street.
When asked if she wanted pie, she replied \"yes\"
You currently have 5 so you decided to give her one

Hello I am confused on how to do this, following the task will help solve the code but I dont understand Task 1 In order to use variables in Java they must firs
Hello I am confused on how to do this, following the task will help solve the code but I dont understand Task 1 In order to use variables in Java they must firs

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site