public static void createmenu5(){
int ch ;
long a , b ;
System.out.print("|No.\t\t| Unit \t\t| Description |\n");
System.out.print("-------------------------------------------------------------|\n");
System.out.print("| 1-\t | Kilobyte (KB)\t\t| 1 KB = 1024 Bytes |\n");
System.out.print("| 2-\t | Megabyte (MB)\t\t| 1 MB = 1024 KB |\n");
System.out.print("| 3-\t | Gigabyte (GB)\t\t| 1 GB = 1024 MB |\n");
System.out.print("| 4-\t | Terabyte (TB)\t\t| 1 TB = 1024 MB |\n");
System.out.print("| 5-\t | Petabyte (PB)\t\t| 1 PB = 1024 TB |\n");
System.out.print("\nMenu that you need to choose:");
System.out.println("1.\tByte:");
System.out.println("2.\tKilobyte:");
System.out.println("3.\tMegabyte:");
System.out.println("4.\tGigabyte:");
System.out.println("5.\tTerabyte:");
System.out.println("6.\tPetabyte:");
System.out.print("You can choose 1 to 6:");
Scanner inputch = new Scanner (System.in);// Create a Scanner object
ch = inputch.nextInt(); // ch is choose
switch(ch) {
case 1:
StorageConverter convertBytes = new StorageConverter() ;
StorageConverter valueByte = new StorageConverter ();//Creating Objects
System.out.print("Enter Bytes = ");
Scanner Byte = new Scanner(System.in);
a = Byte.nextLong(); convertBytes.setA(a);//setter/mutator method
valueByte.setB(1024);
System.out.println("1.\tConvert from Byte to KiloByte = "+(convertBytes.getA()/valueByte.getB())+"KB");//out result of Bytes/1024
System.out.println("2.\tConvert from Byte to MegaByte = "+(convertBytes.getA()/valueByte.getB()/valueByte.getB())+"MB");//out result of Bytes/(1024*1024)
System.out.println("3.\tConvert from Byte to GigaByte = "+(convertBytes.getA()/valueByte.getB()/valueByte.getB()/valueByte.getB())+"GB");//out result of Bytes/(1024*1024*1024)
System.out.println("4.\tConvert from Byte to TeraByte ="+(convertBytes.getA()/valueByte.getB()/valueByte.getB()/valueByte.getB()/valueByte.getB())+"TB");//out result of Bytes/(1024*1024*1024*1024)
System.out.println("5.\tConvert from Byte to PetaByte = "+(convertBytes.getA()/valueByte.getB()/valueByte.getB()/valueByte.getB()/valueByte.getB()/valueByte.getB())+"PB");//out result of Bytes/(1024*1024*1024*1024*1024)
break;
case 2:
StorageConverter convertKilobyte = new StorageConverter() ;
StorageConverter valueKilobyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Kilobyte = ");
Scanner Kilobyte = new Scanner(System.in);
a = Kilobyte.nextLong(); convertKilobyte.setA(a);//setter/mutator method
valueKilobyte.setB(1024);
System.out.println("1.\tConvert from Kilobyte to Byte = "+(convertKilobyte.getA()*valueKilobyte.getB())+"B"
+ "");//out result of Bytes*1024
System.out.println("2.\tConvert from Kilobyte to Megabyte = "+(convertKilobyte.getA()*valueKilobyte.getB())+"MB");//out result of Bytes*1024)
System.out.println("3.\tConvert from Kilobyte to Gigabyte = "+(convertKilobyte.getA()*valueKilobyte.getB()*valueKilobyte.getB())+"GB");//out result of Bytes*(1024*1024)
System.out.println("4.\tConvert from Kilobyte to TeraByte ="+(convertKilobyte.getA()*valueKilobyte.getB()*valueKilobyte.getB()*valueKilobyte.getB())+"TB");//out result of Bytes*(1024*1024*1024)
System.out.println("5.\tConvert from Kilobyte to PetaByte = "+(convertKilobyte.getA()*valueKilobyte.getB()*valueKilobyte.getB()*valueKilobyte.getB()*valueKilobyte.getB())+"PB");//out result of Bytes*(1024*1024*1024*1024)
break;
case 3:
StorageConverter convertMegabyte = new StorageConverter() ;
StorageConverter valueMegabyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Megabyte = ");
Scanner Megabyte = new Scanner(System.in);
a = Megabyte.nextLong(); convertMegabyte.setA(a);//setter/mutator method
valueMegabyte.setB(1024);
System.out.println("1.\tConvert from Megabyte to Byte = "+(convertMegabyte.getA()*valueMegabyte.getB()*valueMegabyte.getB())+"B");//out result of Bytes*(1024*1024)
System.out.println("2.\tConvert from Megabyte to Kilobyte = "+(convertMegabyte.getA()*valueMegabyte.getB())+"KB");//out result of Bytes*1024
System.out.println("3.\tConvert from Megabyte to Gigabyte = "+(convertMegabyte.getA()*valueMegabyte.getB())+"GB");//out result of Bytes*(1024*1024)
System.out.println("4.\tConvert from Megabyte to TeraByte ="+(convertMegabyte.getA()*valueMegabyte.getB()*valueMegabyte.getB())+"TB");//out result of Bytes*(1024*1024)
System.out.println("5.\tConvert from Megabyte to PetaByte = "+(convertMegabyte.getA()*valueMegabyte.getB()*valueMegabyte.getB()*valueMegabyte.getB())+"PB");//out result of Bytes*(1024*1024*1024)
break;
case 4:
StorageConverter convertGigabyte = new StorageConverter() ;
StorageConverter valueGigabyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Gigabyte = ");
Scanner Gigabyte = new Scanner(System.in);
a = Gigabyte.nextLong(); convertGigabyte.setA(a);//setter/mutator method
valueGigabyte.setB(1024);
System.out.println("1.\tConvert from Gigabyte to Byte = "+(convertGigabyte.getA()*valueGigabyte.getB()*valueGigabyte.getB()*valueGigabyte.getB())+"B");//out result of Bytes*(1024*1024*1024)
System.out.println("2.\tConvert from Gigabyte to Kilobyte = "+(convertGigabyte.getA()*valueGigabyte.getB()*valueGigabyte.getB())+"KB");//out result of Bytes*(1024*1024)
System.out.println("3.\tConvert from Gigabyte to Megabyte = "+(convertGigabyte.getA()*valueGigabyte.getB())+"MB");//out result of Bytes*1024
System.out.println("4.\tConvert from Gigabyte to TeraByte ="+(convertGigabyte.getA()*valueGigabyte.getB())+"TB");//out result of Bytes*1024
System.out.println("5.\tConvert from Gigabyte to PetaByte = "+(convertGigabyte.getA()*valueGigabyte.getB()*valueGigabyte.getB())+"PB");//out result of Bytes*(1024*1024)
break;
case 5:
StorageConverter convertTerabyte = new StorageConverter() ;
StorageConverter valueTerabyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Terabyte = ");
Scanner Terabyte = new Scanner(System.in);
a = Terabyte.nextLong(); convertTerabyte.setA(a);//setter/mutator method
valueTerabyte.setB(1024);
System.out.println("1.\tConvert from Terabyte to Byte = "+(convertTerabyte.getA()*valueTerabyte.getB()*valueTerabyte.getB()*valueTerabyte.getB()*valueTerabyte.getB())+"B");//out result of Bytes*(1024*1024*1024*1024)
System.out.println("2.\tConvert from Terabyte to Kilobyte = "+(convertTerabyte.getA()*valueTerabyte.getB()*valueTerabyte.getB()*valueTerabyte.getB())+"KB");//out result of Bytes*(1024*1024*1024)
System.out.println("3.\tConvert from Terabyte to Megabyte = "+(convertTerabyte.getA()*valueTerabyte.getB()*valueTerabyte.getB())+"MB");//out result of Bytes*(1024*1024)
System.out.println("4.\tConvert from Terabyte to Gigabyte ="+(convertTerabyte.getA()*valueTerabyte.getB())+"GB");//out result of Bytes*1024
System.out.println("5.\tConvert from Terabyte to PetaByte = "+(convertTerabyte.getA()*valueTerabyte.getB())+"PB");//out result of Bytes*1024
break;
case 6:
StorageConverter convertPetabyte = new StorageConverter() ;
StorageConverter valuePetabyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Petabyte = ");
Scanner Petabyte = new Scanner(System.in);
a = Petabyte.nextLong(); convertPetabyte.setA(a);//setter/mutator method
valuePetabyte.setB(1024);
System.out.println("1.\tConvert from Petabyte to Byte = "+(convertPetabyte.getA()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB())+"B");//out result of Bytes*(1024*1024*1024*1024*1024)
System.out.println("2.\tConvert from Petabyte to Kilobyte = "+(convertPetabyte.getA()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB())+"KB");//out result of Bytes*(1024*1024*1024*1024)
System.out.println("3.\tConvert from Petabyte to Megabyte = "+(convertPetabyte.getA()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB())+"MB");//out result of Bytes*(1024*1024*1024)
System.out.println("4.\tConvert from Petabyte to Terabyte ="+(convertPetabyte.getA()*valuePetabyte.getB()*valuePetabyte.getB())+"TB");//out result of Bytes*(1024*1024)
System.out.println("5.\tConvert from Petabyte to Gigabyte = "+(convertPetabyte.getA()*valuePetabyte.getB())+"GB");//out result of Bytes*1024
break;
}
}
private long A,B;// can only be accessed through getter and setter methods
public void setA (long a) {
A = a; //getA = setX(int a)
}
public long getA() {
return A ; // Recall A from setA
}
public void setB(long b) {
B = b; //getB = setY(int b)
}
public long getB() {
return B ; // Recall B from setB
}
int ch ;
long a , b ;
System.out.print("|No.\t\t| Unit \t\t| Description |\n");
System.out.print("-------------------------------------------------------------|\n");
System.out.print("| 1-\t | Kilobyte (KB)\t\t| 1 KB = 1024 Bytes |\n");
System.out.print("| 2-\t | Megabyte (MB)\t\t| 1 MB = 1024 KB |\n");
System.out.print("| 3-\t | Gigabyte (GB)\t\t| 1 GB = 1024 MB |\n");
System.out.print("| 4-\t | Terabyte (TB)\t\t| 1 TB = 1024 MB |\n");
System.out.print("| 5-\t | Petabyte (PB)\t\t| 1 PB = 1024 TB |\n");
System.out.print("\nMenu that you need to choose:");
System.out.println("1.\tByte:");
System.out.println("2.\tKilobyte:");
System.out.println("3.\tMegabyte:");
System.out.println("4.\tGigabyte:");
System.out.println("5.\tTerabyte:");
System.out.println("6.\tPetabyte:");
System.out.print("You can choose 1 to 6:");
Scanner inputch = new Scanner (System.in);// Create a Scanner object
ch = inputch.nextInt(); // ch is choose
switch(ch) {
case 1:
StorageConverter convertBytes = new StorageConverter() ;
StorageConverter valueByte = new StorageConverter ();//Creating Objects
System.out.print("Enter Bytes = ");
Scanner Byte = new Scanner(System.in);
a = Byte.nextLong(); convertBytes.setA(a);//setter/mutator method
valueByte.setB(1024);
System.out.println("1.\tConvert from Byte to KiloByte = "+(convertBytes.getA()/valueByte.getB())+"KB");//out result of Bytes/1024
System.out.println("2.\tConvert from Byte to MegaByte = "+(convertBytes.getA()/valueByte.getB()/valueByte.getB())+"MB");//out result of Bytes/(1024*1024)
System.out.println("3.\tConvert from Byte to GigaByte = "+(convertBytes.getA()/valueByte.getB()/valueByte.getB()/valueByte.getB())+"GB");//out result of Bytes/(1024*1024*1024)
System.out.println("4.\tConvert from Byte to TeraByte ="+(convertBytes.getA()/valueByte.getB()/valueByte.getB()/valueByte.getB()/valueByte.getB())+"TB");//out result of Bytes/(1024*1024*1024*1024)
System.out.println("5.\tConvert from Byte to PetaByte = "+(convertBytes.getA()/valueByte.getB()/valueByte.getB()/valueByte.getB()/valueByte.getB()/valueByte.getB())+"PB");//out result of Bytes/(1024*1024*1024*1024*1024)
break;
case 2:
StorageConverter convertKilobyte = new StorageConverter() ;
StorageConverter valueKilobyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Kilobyte = ");
Scanner Kilobyte = new Scanner(System.in);
a = Kilobyte.nextLong(); convertKilobyte.setA(a);//setter/mutator method
valueKilobyte.setB(1024);
System.out.println("1.\tConvert from Kilobyte to Byte = "+(convertKilobyte.getA()*valueKilobyte.getB())+"B"
+ "");//out result of Bytes*1024
System.out.println("2.\tConvert from Kilobyte to Megabyte = "+(convertKilobyte.getA()*valueKilobyte.getB())+"MB");//out result of Bytes*1024)
System.out.println("3.\tConvert from Kilobyte to Gigabyte = "+(convertKilobyte.getA()*valueKilobyte.getB()*valueKilobyte.getB())+"GB");//out result of Bytes*(1024*1024)
System.out.println("4.\tConvert from Kilobyte to TeraByte ="+(convertKilobyte.getA()*valueKilobyte.getB()*valueKilobyte.getB()*valueKilobyte.getB())+"TB");//out result of Bytes*(1024*1024*1024)
System.out.println("5.\tConvert from Kilobyte to PetaByte = "+(convertKilobyte.getA()*valueKilobyte.getB()*valueKilobyte.getB()*valueKilobyte.getB()*valueKilobyte.getB())+"PB");//out result of Bytes*(1024*1024*1024*1024)
break;
case 3:
StorageConverter convertMegabyte = new StorageConverter() ;
StorageConverter valueMegabyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Megabyte = ");
Scanner Megabyte = new Scanner(System.in);
a = Megabyte.nextLong(); convertMegabyte.setA(a);//setter/mutator method
valueMegabyte.setB(1024);
System.out.println("1.\tConvert from Megabyte to Byte = "+(convertMegabyte.getA()*valueMegabyte.getB()*valueMegabyte.getB())+"B");//out result of Bytes*(1024*1024)
System.out.println("2.\tConvert from Megabyte to Kilobyte = "+(convertMegabyte.getA()*valueMegabyte.getB())+"KB");//out result of Bytes*1024
System.out.println("3.\tConvert from Megabyte to Gigabyte = "+(convertMegabyte.getA()*valueMegabyte.getB())+"GB");//out result of Bytes*(1024*1024)
System.out.println("4.\tConvert from Megabyte to TeraByte ="+(convertMegabyte.getA()*valueMegabyte.getB()*valueMegabyte.getB())+"TB");//out result of Bytes*(1024*1024)
System.out.println("5.\tConvert from Megabyte to PetaByte = "+(convertMegabyte.getA()*valueMegabyte.getB()*valueMegabyte.getB()*valueMegabyte.getB())+"PB");//out result of Bytes*(1024*1024*1024)
break;
case 4:
StorageConverter convertGigabyte = new StorageConverter() ;
StorageConverter valueGigabyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Gigabyte = ");
Scanner Gigabyte = new Scanner(System.in);
a = Gigabyte.nextLong(); convertGigabyte.setA(a);//setter/mutator method
valueGigabyte.setB(1024);
System.out.println("1.\tConvert from Gigabyte to Byte = "+(convertGigabyte.getA()*valueGigabyte.getB()*valueGigabyte.getB()*valueGigabyte.getB())+"B");//out result of Bytes*(1024*1024*1024)
System.out.println("2.\tConvert from Gigabyte to Kilobyte = "+(convertGigabyte.getA()*valueGigabyte.getB()*valueGigabyte.getB())+"KB");//out result of Bytes*(1024*1024)
System.out.println("3.\tConvert from Gigabyte to Megabyte = "+(convertGigabyte.getA()*valueGigabyte.getB())+"MB");//out result of Bytes*1024
System.out.println("4.\tConvert from Gigabyte to TeraByte ="+(convertGigabyte.getA()*valueGigabyte.getB())+"TB");//out result of Bytes*1024
System.out.println("5.\tConvert from Gigabyte to PetaByte = "+(convertGigabyte.getA()*valueGigabyte.getB()*valueGigabyte.getB())+"PB");//out result of Bytes*(1024*1024)
break;
case 5:
StorageConverter convertTerabyte = new StorageConverter() ;
StorageConverter valueTerabyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Terabyte = ");
Scanner Terabyte = new Scanner(System.in);
a = Terabyte.nextLong(); convertTerabyte.setA(a);//setter/mutator method
valueTerabyte.setB(1024);
System.out.println("1.\tConvert from Terabyte to Byte = "+(convertTerabyte.getA()*valueTerabyte.getB()*valueTerabyte.getB()*valueTerabyte.getB()*valueTerabyte.getB())+"B");//out result of Bytes*(1024*1024*1024*1024)
System.out.println("2.\tConvert from Terabyte to Kilobyte = "+(convertTerabyte.getA()*valueTerabyte.getB()*valueTerabyte.getB()*valueTerabyte.getB())+"KB");//out result of Bytes*(1024*1024*1024)
System.out.println("3.\tConvert from Terabyte to Megabyte = "+(convertTerabyte.getA()*valueTerabyte.getB()*valueTerabyte.getB())+"MB");//out result of Bytes*(1024*1024)
System.out.println("4.\tConvert from Terabyte to Gigabyte ="+(convertTerabyte.getA()*valueTerabyte.getB())+"GB");//out result of Bytes*1024
System.out.println("5.\tConvert from Terabyte to PetaByte = "+(convertTerabyte.getA()*valueTerabyte.getB())+"PB");//out result of Bytes*1024
break;
case 6:
StorageConverter convertPetabyte = new StorageConverter() ;
StorageConverter valuePetabyte = new StorageConverter ();//Creating Objects
System.out.print("Enter Petabyte = ");
Scanner Petabyte = new Scanner(System.in);
a = Petabyte.nextLong(); convertPetabyte.setA(a);//setter/mutator method
valuePetabyte.setB(1024);
System.out.println("1.\tConvert from Petabyte to Byte = "+(convertPetabyte.getA()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB())+"B");//out result of Bytes*(1024*1024*1024*1024*1024)
System.out.println("2.\tConvert from Petabyte to Kilobyte = "+(convertPetabyte.getA()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB())+"KB");//out result of Bytes*(1024*1024*1024*1024)
System.out.println("3.\tConvert from Petabyte to Megabyte = "+(convertPetabyte.getA()*valuePetabyte.getB()*valuePetabyte.getB()*valuePetabyte.getB())+"MB");//out result of Bytes*(1024*1024*1024)
System.out.println("4.\tConvert from Petabyte to Terabyte ="+(convertPetabyte.getA()*valuePetabyte.getB()*valuePetabyte.getB())+"TB");//out result of Bytes*(1024*1024)
System.out.println("5.\tConvert from Petabyte to Gigabyte = "+(convertPetabyte.getA()*valuePetabyte.getB())+"GB");//out result of Bytes*1024
break;
}
}
private long A,B;// can only be accessed through getter and setter methods
public void setA (long a) {
A = a; //getA = setX(int a)
}
public long getA() {
return A ; // Recall A from setA
}
public void setB(long b) {
B = b; //getB = setY(int b)
}
public long getB() {
return B ; // Recall B from setB
}
Comments
Post a Comment