Tutorial
Tutorial
Tutorial -2
Description:
This tutorial will introduce you to Java fundamentals such as basic primitive type, operators and I/O.
First estimate the below expressions manually and then output each on the console using
System.out.println().
Modify the following program so it prints 1 tab between each word and 2 blank line between each
line of text
class MyPrintingProgram
{
public static void main(String[] args)
{
System.out.println("L1 Word1 Word2 Word3");
System.out.print("L2 Word4 Word5 Word6");
System.out.print("\n L3 Word7 Word8 Word9");
}
}
1. Declare 3 variables:
• An int variable ‘qty’
• A double variable ‘price’
• A string variable ‘name’
2. Store quantity , price and name of a product in these variables by assigning literal values
to these variables.
3. The program should display these values on the screen as follows, using a mix of text and
above variables
Follow the same steps as in Exercise 3, but change the step 2 to ask the user for input for these
values by using Scanner class.