Starting from:

$25

CSE021-Lab 2 Solved

1.      I used 15 variables.

2.      The types of variables I used in this lab are int and double.

3.      I decided to use int for the Red Hawk’s discount because it is buy 2 and get 1 free; since for the discount to work you’d have to multiply the integer part of the amount of Red Hawk cheese. I used double because we are going to need numbers that are multiples of 0.5 and that also includes decimals. If we only used int, we would have some lost data and the total wouldn’t be accurate.

4.      The difference between print and println is that print will only print what is inside of it and continue on the same unless you put \n inside of the print. Println will print what is inside of it, but it will include a new line below it rather than continue in the same line.  

5.      Yes, I used both. I used print for the simple commands that do not include new lines. I used println when I need to print something within the for loop so it doesn’t repeat the same thing on the same line.

6.      System.out.println(); would produce a newline after printing whatever is inside of it.

More products