Sheet Java
1. Write a program to compute the area and circumference of a rectangle 3 inche wide by 5 inches long.
What changes must be made to the program so it works for a rectangle 6.8 inches wide by 2.3 inches long? public class AreaOfRectangle {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here int width=3,height=5;
// double width=6.8,height=2.3; int area,circumference;
// double area,circumference; area = width * height; circumference = 2 *( width + height);
System.out.println("The area of rectangle is "+ area+" the circumference is "+ circumference);
}
}
2- Write a program to print your name, and date of birth? …show more content…
package sum.of.the.array; import java.util.Scanner;
/**
*
* @author hayam
*/
public class SumOfTheArray {
/**
* @param args the command line arguments
1
*/ public static void main(String[] args) {
// TODO code application logic here int size,sum=0;
Scanner scan = new Scanner (System.in);
System.out.println("Enter the size of the array "); size=scan.nextInt(); int [] x = new int [size]; for( int i=0;i=81 || x==90)
System.out.println("B");
else if (x>=71 || x==80) …show more content…
package count.positive; import java.util.Scanner;
/**
*
* @author hayam
*/
public class CountPositive {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
14
int size, count=0,n=0;
Scanner scan = new Scanner (System.in);
System.out.println("Enter the size of the array "); size= scan.nextInt(); int [] x = new int [size]; for( int i=0;i 0)
System.out.println("The positive value is " + ++ count); else if