Question: Objectives of this lab: In this lab, Students will implement some of the basic concepts learned in computer science I course. They will declare, instantiate,

 Objectives of this lab: In this lab, Students will implement some
of the basic concepts learned in computer science I course. They will
declare, instantiate, and use variables, print, prompt user for input, use arrays,
try if-else, loop statements, and methods. 1- Declaring, instantiating, and using local
variables In Java, to declare a local variable (what is a local
variable?), you write the data type and then the name of the

Objectives of this lab: In this lab, Students will implement some of the basic concepts learned in computer science I course. They will declare, instantiate, and use variables, print, prompt user for input, use arrays, try if-else, loop statements, and methods. 1- Declaring, instantiating, and using local variables In Java, to declare a local variable (what is a local variable?), you write the data type and then the name of the variable and then you type a semicolon to finish the statement like this: int number; Here you declared a variable of type integer and named it "number" ---But wait! Where do I write this?! Put your declaration line "int number;" inside your main method "public static void main(String[] args)" instantiating your variables would follow the syntax in the following example: int number=5; Declare a double variable, call it mydouble and give it the value 2.5 and then print it. Remember: You can always apply mathematical operations in java (addition, subtraction multiplication and division, mod, ++, --, etc) 2- Getting user input To get input from user, you must first import a library to enable you to do this. To import a library, go to the very beginning of your java file, go to the line right after the package line and right the following: import java.util.Scanner; java.util.Scanner is the name of the library we need. After importing your library, write the following inside your main method Scanner input = new Scanner(System.in); -- Do not worry if you do not fully understand the structure of the previous statement, you will be able to understand throughout the course. To take integer input from the user you will write the following inside your main method: int myNumber=input.nextInt(); to take double input you will do the following: double myNumber

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!