0% found this document useful (0 votes)
59 views8 pages

Java Programs for Basic Calculations

The document contains code for two Java programs. The first program calculates the sum of the first 50 numbers. The second program converts pressure values from psi to mmHg, ft H2O, and bar, with the user inputting a starting and ending pressure with an increment of 5 psi. It then prints the converted values in a table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views8 pages

Java Programs for Basic Calculations

The document contains code for two Java programs. The first program calculates the sum of the first 50 numbers. The second program converts pressure values from psi to mmHg, ft H2O, and bar, with the user inputting a starting and ending pressure with an increment of 5 psi. It then prints the converted values in a table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

October 14, 2017

1. Create a java program that will compute for the sum of the 1st 50 numbers.
2, Calculate a program that will convert pressure of psi to mmHg, ft H2O, &bar with an increment of
5.0psi. the user will input the starting &ending pressure value
jackage javaapplication1;
import [Link];
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner([Link]);
int n=1, s=n;
do
{
[Link]("sum:"+s);
n=n+1;
s=s+n;
}
while (n<=50);
}

public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input=new Scanner([Link]);
[Link]("input starting pressure in psi:");
Double A,B,X,Y,Z;
A=[Link]();
[Link]("input ending pressure in psi:");
B=[Link]();
[Link](" psi");
[Link]("\t\tmmHg");
[Link]("\t fth2O");
[Link]("\t bar");
do
{
X=A*(760/14.7);
Y=A*(33.899/14.7);
Z=A*(1.01325/14.7);
[Link]("%1.4f\t%1.4f\t%1.4f\t%1.4f\n",A,X,Y,Z);
A=5+A;
}
while (A<=B);
}
}
PRACTICE (OCT 20,2017)
SW
[Link] the specific gravity of a substance in terms of Brix, API, Tw. the user will input density
of substance (starting and ending value) w/ increment of 25.0 thereafter.
2. a certain solution reads 55 degree Brix and flows thru pipe of length 2m and diameter of 30cm. It
flows thru the cross section for a minute. the soln has an internal resistance of 1.2cP. Calculate its mass
flowrate, density, and Re for a Brix increment of 10 thereafter. the user will input ending value!!!

You might also like