write me instructions for following of what I'm supposed to learn for each steps and how…
- User
write me instructions for following of what I'm supposed to learn for each steps and how it works:
APCS Unit 1 Primitive Datatypes, Variables, Assignment Statements, Expressions Specification Create a project in repl called Unit1. Create a new class in the project called DatatypeVariablesAssignment. (1) Create a run method in the class that does the following: Create a variable of each primitive data type available in Java. Set the value of each with a literal of the appropriate type. Create a variable of each primitive data type required for the AP exam. Set the value of each with Scanner and the corresponding conversion method for each type. When you run the program, observe what happens when you input a string that looks wrong? Print out the values for the primitives with System.out.println(). For this you only need to print out the values. Print out the values for the AP primitives with System.out.format(). For this create formatted output with labels. The output in the terminal should look like this: int: 23 double: 5.123 boolean: false String: APCS Call DatatypeVariablesAssignment.run() from Main.main(). Define a typeTest method in your class. It should use the following method signature:
public static void typeTest()
The method should do the following things: (2) Create 6 new integer variables as follows. Print the results using System.out.format(). Observe patterns. 2 should be set using Scanner. 1 should contain the sum of 2 integers 1 should contain the difference of 2 integers 1 should contain the product of 2 integers 1 should contain the quotient of 2 integers (3) Create 6 new double variables as follows. Print the results using System.out.format(). Observe patterns. 2 should be set using Scanner. 1 should contain the sum of 2 doubles 1 should contain the difference of 2 doubles 1 should contain the product of 2 doubles 1 should contain the quotient of 2 doubles (4) Create 4 new int variables as follows. Print the results using System.out.format(). Observe patterns. 2 should be set using Scanner. 1 should contain the sum of 2 doubles 1 should contain the difference of 2 doubles 1 should contain the product of 2 doubles 1 should contain the quotient of 2 doubles (5) Create 4 new double variables as follows. Print the results using System.out.format(). Observe patterns. The 2 operands should be set using Scanner. 1 should contain the sum of 1 integer and 1 integer 1 should contain the difference of 1 integer and 1 integer 1 should contain the product of 1 integer and 1 integer 1 should contain the quotient of 1 integer and 1 integer (6) Create 4 new integer variables as follows. Print the results using System.out.format(). Observe patterns. The 2 operands should be set using Scanner. 1 should contain the sum of 1 integer and 1 double 1 should contain the difference of 1 integer and 1 double 1 should contain the product of 1 integer and 1 double 1 should contain the quotient of 1 integer and 1 double (7) Create 4 new double variables as follows. Print the results using System.out.format(). Observe patterns. The 2 operands should be set using Scanner. 1 should contain the sum of 1 integer and 1 double 1 should contain the difference of 1 integer and 1 double 1 should contain the product of 1 integer and 1 double 1 should contain the quotient of 1 integer and 1 double
- Assistant
- User
show step to step of what I should write and explain how each line or codes worka and what it means
- Assistant
- User
write how to type the code too
- Assistant
Sure! Here's a step-by-step guide on how to type the code for each step:
Step 1: Creating the run method
-
Open the repl and create a new project called Unit1.
- Type:
repl create Unit1
- Type:
-
Inside the Unit1 project, create a new class called DatatypeVariablesAssignment.
- Type:
repl open Unit1 - Then create a new file called
DatatypeVariablesAssignment.javaand open it.
- Type:
-
In the DatatypeVariablesAssignment class, create a method called "run" with the following method signature:
public static void run() { // Code goes here }
Step 2: Creating variables of primitive data types
-
Inside the run method, create a variable for each primitive data type available in Java:
-