Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- *
- * @author 261141
- */
- public class IdealGasLaw1 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner s = new Scanner(System.in);
- Scanner in = new Scanner(System.in);
- String answer;
- System.out.println("What do you want to solve for?");
- answer = s.nextLine();
- System.out.print("Pressure? (in Torr) ");
- double pressure = in.nextDouble();
- System.out.print("Volume? (in liters) ");
- double volume = in.nextDouble();
- System.out.print("Temp ? (in Kelvin) ");
- double temp = in.nextDouble();
- System.out.print("Moles? ");
- double moles = in.nextDouble();
- double gas = 62;
- double PresAns = (pressure)*(volume)/gas * (temp+273);
- double MoleAns = (pressure)*(moles);
- if (answer.equals("Moles" )) {
- System.out.println("Moles =" +MoleAns +" moles");
- }
- else
- System.out.println("Pressure =: "+PresAns +" Torr");
- }
- }
Add Comment
Please, Sign In to add comment