0% found this document useful (0 votes)
10 views2 pages

Import Java

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Import Java

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

*;
class Main {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);

System.out.println("Cyrus Kyle T. Valencia\n");


int radius;
float pi=3.1416f;
float area;
float circumference;
System.out.println("Circle Shape\n");
System.out.print("Enter the radius: ");
radius=in.nextInt();
area = pi*(radius*radius);
circumference = 2*pi*radius;
System.out.printf("Area: %.2f",area);
System.out.printf("\nCircumference; %.2f\n",circumference);

int base;
int height;
float perimeter;
int side1;
int side2;
int side3;
System.out.println("\nTriangle Shape\n");
System.out.print("Enter the base: ");
base=in.nextInt();
System.out.print("Enter the height: ");
height=in.nextInt();
area=(1/2.0f)*base*height;
System.out.printf("Area: %.2f\n",area);

//Activity 2 perimeter
System.out.print("\nEnter the first side: ");
side1=in.nextInt();
System.out.print("Enter the second side: ");
side2=in.nextInt();
System.out.print("Enter the third side: ");
side3=in.nextInt();
perimeter= side1+side2+side3;
System.out.printf("Perimeter: %.2f\n",perimeter);

//Activity3
int length;
int width;

System.out.println("\nRectangle Shape\n");
System.out.print("Enter the length: ");
length=in.nextInt();
System.out.print("Enter the width: ");
width=in.nextInt();
area=length*width;
perimeter=2*(length+width);
System.out.printf("Area: %.2f\n",area);
System.out.printf("Perimeter: %.2f\n",perimeter);

// Activity4
int heightVertical;
int side;
System.out.println("\nParallelogram shape");
System.out.print("\nEnter side: ");
side=in.nextInt();
System.out.print("Enter base: ");
base=in.nextInt();
System.out.print("Enter vertical height: ");
heightVertical=in.nextInt();
area=base*heightVertical;
perimeter=2*(side+base);
System.out.printf("Area: %.2f\n",area);
System.out.printf("Perimeter: %.2f\n",perimeter);

//Activity 5
int celsius;
int fahrenheit;
System.out.println("\nConvertion of temperature\n");
System.out.print("Enter a temperature in celsius: ");
celsius=in.nextInt();
fahrenheit=(celsius*9/5)+32;
System.out.println(celsius+" degrees Celsius is "+fahrenheit+" degrees Fahrenheit.");

}
}

You might also like