0% found this document useful (0 votes)
4 views

Assignment 2 Java 57

The document contains Java code for multiple assignments on object-oriented programming. It includes programs for capturing user information, calculating the area of a circle, and calculating the area of a triangle. Each program prompts the user for input and displays the calculated results based on the provided data.

Uploaded by

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

Assignment 2 Java 57

The document contains Java code for multiple assignments on object-oriented programming. It includes programs for capturing user information, calculating the area of a circle, and calculating the area of a triangle. Each program prompts the user for input and displays the calculated results based on the provided data.

Uploaded by

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

ASSIGNMENT NO.

OBJECT ORIENTED PROGRAMMING USING JAVA

NAME-SHREEYA JOSHI
ROLLNO.-57
PRN-2122000723

Q1)

import java.math.BigInteger;
import java .util.Scanner ;
public class Main {
public static void main(String[] ignoredArgs){
String name;
String gender;
int age;
BigInteger Phonenumber;
int Cetscore;

Scanner scanner = new Scanner(System.in);


System.out.println("enter your name:");
name = scanner.nextLine();
System.out.println("your name is "+name);
System.out.println("enter your gender:");
gender =scanner.nextLine();
System.out.println("your gender is "+gender);
System.out.println("enter your age");
age= scanner.nextInt();
System.out.println("your age is "+age);
System.out.println("enter your phonenumber");
Phonenumber= scanner.nextBigInteger();
System.out.println("your PHONENUMBER is "+Phonenumber);
System.out.println("enter your cet score");
Cetscore= scanner.nextInt();
System.out.println("your Cetscore is "+Cetscore);
if (age < 25 ) {
System.out.println("Student can get 25%\n" +
"discount on Bus Pass");
}else {
System.out.println("Student can get 30 %\n" +
"discount on Bus Pass.");
}

}
}

Q2)
import java .util.Scanner ;
public class Main {
public static void main(String[] ignoredArgs){
int radius;
float area;
System.out.println("enter radius of circle:" );
Scanner sc = new Scanner(System.in);
radius= sc.nextInt();
area= (float) (3.14*radius*radius);
System.out.println("area of circle is "+area);

}
Q3)
import java .util.Scanner ;
public class Main {
public static void main(String[] ignoredArgs){
int base,height;
float area;
Scanner sc = new Scanner(System.in);
System.out.println("enter height of triangle");
height=sc.nextInt();
System.out.println("enter base");
base=sc.nextInt();
area= (float) (0.5*base*height);
System.out.println("area of circle is "+area);

}
Q4)
mport java .util.Scanner ;
public class Main {
public static void main(String[] ignoredArgs){
int radius;
float area;
System.out.println("enter radius of circle:" );
Scanner sc = new Scanner(System.in);
radius= sc.nextInt();
area= (float) (3.14*radius*radius);
System.out.println("area of circle is "+area);
int base,height;
float area;
System.out.println("enter height of triangle");
height=sc.nextInt();
System.out.println("enter base");
base=sc.nextInt();
area= (float) (0.5*base*height);
System.out.println("area of circle is "+area);

You might also like