You are on page 1of 3

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package valdez_switchpractice;

import java.util.Scanner;

/**

* @author user3

*/

public class VALDEZ_SWITCHPRACTICE {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

Scanner ccv = new Scanner(System.in);

double answer, SG, D;

int choice;

System.out.print("1. BAUME \n");

System.out.print("2. API \n");


System.out.print("3. TWADDELL \n");

System.out.print("4. BRIX \n");

System.out.print("What specific gravity converter to be used: ");

choice = ccv.nextInt();

switch (choice)

case 1:

System.out.print("Input Density in g/cm3: ");

D = ccv.nextDouble();

SG = (D/1);

if (SG >= 1)

answer = (145 - (145/SG));

System.out.printf("The specific gravity in Degrees Baume is %.6f \n ", answer);

else

answer = ((140/SG) - 130);

System.out.printf("The Specific Gravity in Degrees Baume is %.6f \n ", answer);

break;

case 2:

System.out.print("Input Density in g/cm3: ");

D = ccv.nextDouble();
SG = (D/1);

answer = ((141.5/SG)-131.5);

System.out.printf("The Specific Gravity in Degrees API is %.6f \n ", answer);

break;

case 3:

System.out.print("Input Density in g/cm3: ");

D = ccv.nextDouble();

SG = (D/1);

answer = ((SG-1)/0.005);

System.out.printf("The Specific Gravity in Degrees Twaddell is %.6f \n ", answer);

break;

case 4:

System.out.print("Input Density in g/cm3: ");

D = ccv.nextDouble();

SG = (D/1);

answer = ((SG-1)/0.004);

System.out.printf("The Specific Gravity in Degrees Brix is %.6f \n ", answer);

break;

default:

System.out.println("Conversion unidentified!");

break;

You might also like