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

Class 11 Programming

The document contains three Java programs: the first calculates the volume, total surface area, or diagonal of a cuboid; the second computes an annual bonus based on employee grade and monthly salary; and the third determines the volume of a cylinder, cone, or sphere based on user input. Each program uses a switch-case structure to handle user choices and perform calculations accordingly. The code snippets demonstrate basic input handling and mathematical operations in Java.

Uploaded by

berojgar06
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)
2 views8 pages

Class 11 Programming

The document contains three Java programs: the first calculates the volume, total surface area, or diagonal of a cuboid; the second computes an annual bonus based on employee grade and monthly salary; and the third determines the volume of a cylinder, cone, or sphere based on user input. Each program uses a switch-case structure to handle user choices and perform calculations accordingly. The code snippets demonstrate basic input handling and mathematical operations in Java.

Uploaded by

berojgar06
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

Page no 223.

Program No 1

import [Link];

class CuboidMenu
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);

double l, b, h;
int choice;

[Link]("Enter length: ");


l = [Link]();

[Link]("Enter breadth: ");


b = [Link]();
[Link]("Enter height: ");
h = [Link]();

[Link]("\n1. Volume");
[Link]("2. Total Surface Area");
[Link]("3. Diagonal");
[Link]("Enter your choice: ");
choice = [Link]();

switch(choice)
{
case 1:
double volume = l * b * h;
[Link]("Volume = " + volume);
break;

case 2:
double tsa = 2 * (l*b + b*h + l*h);
[Link]("Total Surface Area = " + tsa);
break;
case 3:
double diagonal = [Link](l*l + b*b + h*h);
[Link]("Diagonal = " + diagonal);
break;

default:
[Link]("Invalid choice");
}
}
}

Prog 2
Import [Link];

Class BonusCalculator
{
Public static void main(String args[])
{
Scanner sc = new Scanner([Link]);

Char grade;
Double basic, annualBasic, bonus = 0;

[Link](“Enter grade (A/B/C): “);


Grade = [Link]().charAt(0);

[Link](“Enter monthly basic salary: “);


Basic = [Link]();

annualBasic = basic * 12;

switch(grade)
{
Case ‘A’:
Case ‘a’:
Bonus = annualBasic * 12 / 100;
If(bonus > 50000)
Bonus = 50000;
Break;

Case ‘B’:
Case ‘b’:
Bonus = annualBasic * 10 / 100;
If(bonus > 40000)
Bonus = 40000;
Break;

Case ‘C’:
Case ‘c’:
Bonus = annualBasic * 8.33 / 100;
If(bonus > 30000)
Bonus = 30000;
Break;

Default:
[Link](“Invalid grade”);
[Link](0);
}

[Link](“Annual Bonus = ₹ “ + bonus);


}
}
Program 3

Import [Link];

Class VolumeMenu
{
Public static void main(String args[])
{
Scanner sc = new Scanner([Link]);

Int choice;
Double r, h, volume;

[Link](“1. Cylinder”);
[Link](“2. Cone”);
[Link](“3. Sphere”);
[Link](“Enter your choice: “);
Choice = [Link]();

Switch(choice)
{
Case 1:
[Link](“Enter radius: “);
R = [Link]();
[Link](“Enter height: “);
H = [Link]();

Volume = [Link] * r * r * h;
[Link](“Volume of Cylinder = “ + volume);
Break;

Case 2:
[Link](“Enter radius: “);
R = [Link]();
[Link](“Enter height: “);
H = [Link]();

Volume = (1.0/3) * [Link] * r * r * h;


[Link](“Volume of Cone = “ + volume);
Break;

Case 3:
[Link](“Enter radius: “);
R = [Link]();

Volume = (4.0/3) * [Link] * r * r * r;


[Link](“Volume of Sphere = “ + volume);
Break;

Default:
[Link](“Invalid choice”);
}
}
}

You might also like