-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasic.java
59 lines (51 loc) · 2.04 KB
/
Basic.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.*;
class OutputFormat{
void stringformat(){
System.out.printf("--------------------------------%n");
System.out.printf(" Java's Primitive Types %n");
System.out.printf(" (String printf example) %n");
System.out.printf("--------------------------------%n");
System.out.printf("| %-10s | %-8s | %4s |%n", "CATEGORY", "NAME", "BITS");
System.out.printf("--------------------------------%n");
System.out.printf("| %-10s | %-8s | %4s |%n", "Floating", "double", "0064");
System.out.printf("| %-10s | %-8s | %4s |%n", "Floating", "float", "0032");
System.out.printf("| %-10s | %-8s | %4s |%n", "Integral", "long", "0064");
System.out.printf("| %-10s | %-8s | %4s |%n", "Integral", "int", "0032");
System.out.printf("| %-10s | %-8s | %4s |%n", "Integral", "char", "0016");
System.out.printf("| %-10s | %-8s | %4s |%n", "Integral", "short", "0016");
System.out.printf("| %-10s | %-8s | %4s |%n", "Integral", "byte", "0008");
System.out.printf("| %-10s | %-8s | %4s |%n", "Boolean", "boolean", "0001");
System.out.printf("--------------------------------%n");
}
}
class PrimitiveDataTypes{
Scanner sc = new Scanner(System.in);
void readdata(){
int integer = sc.nextInt();
float number = sc.nextFloat();
String str = sc.nextLine();
boolean bool = sc.nextBoolean();
double d = sc.nextDouble();
}
}
public class Basic {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int choice;
do{
System.out.println("0.End 1.Output-Formatting 2.Primitive-data-types ");
System.out.print("Enter your choice(number): ");
choice = sc.nextInt();
switch(choice){
case 1 :{
OutputFormat obj1 = new OutputFormat();
obj1.stringformat();
}
case 2:{
PrimitiveDataTypes obj2 = new PrimitiveDataTypes();
obj2.readdata();
}
}
}while(choice!=0);
}
}