Question
Objective: The ICS student will create a Java program that will demonstrate their understanding of variable declaration and initialization, as well as arithmetic operations. Related
Objective: The ICS student will create a Java program that will demonstrate their understanding of variable declaration and initialization, as well as arithmetic operations.
Related SLOs:
SLO #1: Use an appropriate programming environment to design, code, compile, run, and debug computer programs.
SLO #4: Demonstrate working with primitive data types, strings, and arrays.
Instructions:
Using jGRASP, write a Java program named LastnameFirstname02.java, using your last name and your first name, that does the following:
Declare and print the values of 5 variables, using each of the following data types: int, double, char, boolean, String
In other words, you should use 1 int variable, 1 double variable, 1 char variable, etc.
When printing the value of your variables, use it in a sentence.
In the example below, the sentence "My dog's age is 5." prints the int variable with a value of 5
Important: Do not simply print an entire sentence -- you need to print the variable as part of your sentence.
Create a constant, then perform an arithmetic operation using the value of the constant
Remember what a constant is used for: values you don't expect to change
In the example below, a constant value is used to convert 8 inches into centimeters
Note: You can have similar output to the example below, but feel free to write your own text!
Remember to always begin your code with the following documentation comments:
/**
* Short description of the program.
*
* @author Doe John
* @assignment ICS 111 Assignment 02
* @date 01/17/2023
* @bugs Short description of bugs in the program, if any.
*/
Expected Output:
This is an example of what your program should output:
----jGRASP exec: java DoeJohn2
This sentence prints a char variable and String variable:
My dog's age is 5. His name is Snoopy!
This sentence prints a double variable:
A bubble tea costs $4.95.
The second sentence prints a boolean variable:
Is computer science cool, true or false?
Hmmmmm... I'd have to say.... true!!!
The first sentence prints an int variable.
The second sentence uses the int value and constant for an arithmetic operation:
Snoopy's tail is 8 inches long.
This is equivalent to 20.32 centimeters!
----jGRASP: operation complete.
Criteria:
-correct creation and use of each type of variable
-correct creation and use of a constant in an arithmetic operation
-output that clearly explains to the user what is happening in the program
-avoid miscellaneous mistakes, bugs, or problems
Step by Step Solution
3.45 Rating (177 Votes )
There are 3 Steps involved in it
Step: 1
Solution Here is a possible solution for your task java A program that demonstrates variable declara...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started