Wednesday, 26 September 2018

Choong Kar Yee
182630
Lab1

1.
public test 1

public class Test1 {
public static void main(String[] args)  {
double i = 50.0;
double k = i + 50.0;
double j = k + 1;
System.out.println("j is:" +j+ "and k is:" +k);
}
}



public class Test2 {
public static void main(String[] args) {
int k = 1;
int i = k + 2;
System.out.println("i is" + i );
}
}





public class Test3 {
public static void main(String[] args) {
int i, j, k;
i = j = k = 2;
System.out.println("i is" + i + "j is" + j + "k is" + k);
}
}



public class Test4{
public static void main(String[] args)
{
int amount = 5;
System.out.println(amount/2);
}
}





public class Test5{
public static void main(String[] args)
{
double interestRate = 0.05;
double interest = interestRate * 10000;
System.out.println("interest is " + interest);
}
}




public class Test6
{
public static void main(String[] args)
{
int value = 2147483647 + 1;
System.out.println("value is " + value);
}
}


public class Test7
{
public static void main(String[] args)
{
int value = -2147483646 - 1;
System.out.println("value is"  + value);
}
}



public class Test8
{
public static void main(String[] args){
System.out.println("1.0 - 0.9");
}
}





public class Test9
{
public static void main(String[] args) {
double value=1/1;
System.out.println("value is" + value);
}
}




public class CelsiusToFahrenheit {
public static void main(String[] args)
{
System.out.println("35.0 celsius is 95.0 Fahrenheit.");
System.out.println("The conversion formula at the bottom should produce 95.0.");
System.out.println("But it does not. So, how to correct it?");
System.out.println((35*9/5) + 32 );
}
}





public class Welcome
{
public static void main(String[] args) {
System.out.println("Fundamental First!");
System.out.println("Excellence follow suit!");
}
}


2.

a
Data                     
Process
Output
Number of square feet of land
Calculate the number of acres of land
Number of acres of land with square


b
Data                     
Process
Output
Three test scores
Calculate the average of three test scores
Average of three test scores

c
Data                     
Process
Output
Percentage profit and retail price of circuit boards
Calculate profit of circuit board
Profit of circuit board




3.
 a

Data                     
Processing
Output
Acceleration a and take-off speed v
Calculate the minimum runway length needed
Value of minimum runway length needed

public class Airplane {
public static void main(String[] args)
{
double v=60;
double a=3.5;
double length=v*v/(2*a);
System.out.println("length is" + length);
}
}




No comments:

Post a Comment

lab 10 1. import java.util.Scanner; public class Test1{      public static void main(String []args){               Scanner input =...