Anda di halaman 1dari 3

**************SAMPLE CODE TO TAKE INPUT FROM A USER***************

import java.util.Scanner;

class Test
{

public static void main(String s1[])


{
Scanner scan = new Scanner(System.in);

System.out.println("enter a number");
int i = scan.nextInt();
System.out.println(i);

}
}

Assignments:
1. Checking your java version
2. Wildcards in java (like new-line, ", tab etc ) try using them in sop
3. Two type of comment practise in java program.
4. WAP to displays your details on screen in a letter format. Like the way given below.

*---------------------------------------------------------------------------------------------------------------------*
| |
| |
| |
| |
| |
| |
| |
| Name |
| Other details line 1 |
| Other details line 1 |
|
|
| |
*---------------------------------------------------------------------------------------------------------------------*

5.try and use all these given operators in your program


+ plus
- minus
/ slash
* asterisk
% percent
< less-than
> greater-than
<= less-than-or-equal
>= greater-than-or-equal
6. Print all the characters while sorting them according to the ASCII codes(from 1 to 200) in
increasing order(use for loop). Output must be in a tabular format and each line must contain 5
entries like given below. Use some kind of a separator between columns (|)

Ascii code -> Ascii code -> Ascii code -> Ascii code -> Ascii code ->
char char char char char

Ascii code -> Ascii code -> Ascii code -> Ascii code -> Ascii code ->
char char char char char

Ascii code -> Ascii code -> Ascii code -> Ascii code -> Ascii code ->
char char char char char

7. From the given three numbers find the largest.


a= something, b= something, c= something.

8 .Input- day number. Output - day name

1 sunday

2 monday

3 tuesday

4 wednesday

5 thursday

6 friday

7 saturday

8 sunday

Anything else error...

Anda mungkin juga menyukai