Project
Project
Variable listing
Variable Datatype Input Output Function
num int To input _____ To check
variable that if a
number is
divisible
by 3 as
well as 5.
Variable listing
Variable Data Type Input Output Function
yr int To input ______ To check
vaiable that a year
is a leap
year or a
century
leap year
or century
year
if (a < 0 || b < 0) {
System.out.println("Square root of a negative number
can't be determined");
}
else {
double sqrtA = Math.sqrt(a);
double sqrtB = Math.sqrt(b);
double isAPerfectSq = sqrtA - Math.floor(sqrtA);
double isBPerfectSq = sqrtB - Math.floor(sqrtB);
Variable listing
Variable Data Type Input Output Function
a Int To input To print if To check
variable the that if the
number is number is
perfect a perfect
square square or
not
b Int To input To print if To check
variable the that if the
number is number is
a perfect perfect
square square or
not
4. /*to input the total cost and display the amount to be paid
by the customer*/
import java.util.*; //Import java packages
}
}
Variable listing
Variable Data Type Input Output Function
cost double To input To input
the total ________ the total
cost price
gift string To print To find
the gift out the gift
amt double To print To get the
the final price
amount to to be paid
be paid
5./*to input the name, age and taxable income and display the
payable income tax*/
import java.util.*; //import java packages
Variable Listing
7.//to input the sum assured of the policy holder and display
the name, sum assured and first premium
import java.util.*; // Import java packages
class prog_4 // Declare the class
{
public static void main(String args[]) //main method
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Name: ");
String name = in.nextLine();
System.out.print("Enter Sum Assured: ");
double sum = in.nextDouble();
System.out.print("Enter First Premium: ");
double pre = in.nextDouble();
double disc = 0.0, comm = 0.0;
}
}
Variable listing
8.//to accept the name and basic salary and display gross
salary
import java.util.*; // Import java package
Variable listing
9.//to calculate and display the volume of solids
import java.util.*; // Import java packages
switch(choice)
{
case 1:
System.out.print("Enter length of cuboid: ");
double l = in.nextDouble();
System.out.print("Enter breadth of cuboid: ");
double b = in.nextDouble();
System.out.print("Enter height of cuboid: ");
double h = in.nextDouble();
double vol = l * b * h;
System.out.println("Volume of cuboid = " + vol);
break;
case 2:
System.out.print("Enter radius of cylinder: ");
double rCylinder = in.nextDouble();
System.out.print("Enter height of cylinder: ");
double hCylinder = in.nextDouble();
double vCylinder = (22 / 7.0) *
Math.pow(rCylinder, 2) * hCylinder;
System.out.println("Volume of cylinder = " +
vCylinder);
break;
case 3:
System.out.print("Enter radius of cone: ");
double rCone = in.nextDouble();
System.out.print("Enter height of cone: ");
double hCone = in.nextDouble();
double vCone = (1 / 3.0) * (22 / 7.0) *
Math.pow(rCone, 2) * hCone;
System.out.println("Volume of cone = " + vCone);
break;
default:
System.out.println("Wrong choice! Please select
from 1 or 2 or 3.");
}
}
}
Variable listing
8.//to input and display the amount paid by a customer for
laptop or destop
class prog_5 //Declare the class
{
public static void main(String args[]) //main method
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Name: ");
String name = in.nextLine();
System.out.print("Enter Amount of Purchase: ");
double amt = in.nextDouble();
System.out.println("Enter Type of Purchase");
System.out.print("'L'- Laptop or 'D'- Desktop: ");
char type = in.next().charAt(0);
type = Character.toUpperCase(type);
double disc = 0.0;