0% found this document useful (0 votes)
5 views24 pages

9 Code For Project

The document contains Java code for ten different programs, each demonstrating various functionalities such as calculating volumes of geometric shapes, computing parcel charges based on weight, calculating interest for term deposits, finding the second smallest number among three inputs, and checking for special two-digit numbers. Additionally, it includes programs for summing positive and negative numbers, removing zeros from a number, and checking for palindrome and perfect numbers. Each program is structured with user input and output statements to guide the user through the operations.

Uploaded by

malakarguddu09
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)
5 views24 pages

9 Code For Project

The document contains Java code for ten different programs, each demonstrating various functionalities such as calculating volumes of geometric shapes, computing parcel charges based on weight, calculating interest for term deposits, finding the second smallest number among three inputs, and checking for special two-digit numbers. Additionally, it includes programs for summing positive and negative numbers, removing zeros from a number, and checking for palindrome and perfect numbers. Each program is structured with user input and output statements to guide the user through the operations.

Uploaded by

malakarguddu09
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

Code for program 1

import [Link].*;

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

int ch;
double v, l, b, h, r;

[Link]("1. Volume of Cuboid");


[Link]("2. Volume of Cylinder");
[Link]("3. Volume of Cone");
[Link]("Enter your choice: ");
ch = [Link]();

switch(ch)
{
case 1:
[Link]("Enter length: ");
l = [Link]();

[Link]("Enter breadth: ");


b = [Link]();

[Link]("Enter height: ");


h = [Link]();

v = l * b * h;
[Link]("Volume of Cuboid = " + v);
break;

case 2:
[Link]("Enter radius: ");
r = [Link]();

[Link]("Enter height: ");


h = [Link]();

v = [Link] * r * r * h;

[Link]("Volume of Cylinder = " + v);


break;
Code for program 1

case 3:
[Link]("Enter radius: ");
r = [Link]();

[Link]("Enter height: ");


h = [Link]();

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

[Link]("Volume of Cone = " + v);


break;

default:
[Link]("Invalid Choice");
}
}
}
Output for program 1
Code for program 2

import [Link].*;
class proj_2
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
double weight, charge = 0;
[Link]("Charges for Parcel ");
[Link]("___________________ ");
[Link]("Weight\t\t\tCharges ");
[Link]("Upto 10 kg\t\t Rs. 30 per kg ");
[Link]("Next 20 kg\t\t Rs. 20 per kg ");
[Link]("Above 30 kg\t\t Rs.15 per kg ");
[Link]();
[Link]("Enter weight of parcel in Kg: ");
weight = [Link]();
if(weight <= 10)
charge = weight * 30;
else if(weight <= 30)
charge = (10 * 30) + ((weight - 10) * 20);
else
charge = (10 * 30) + (20 * 20) + ((weight - 30) * 15);
[Link]("Total Charge = Rs. " + charge);
}
}
Output for program 2
Code for program 3
import [Link].*;

class proj_3
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
double sum, rate, interest, maturity;
int days;
[Link]("Interest for Term Deposite ");
[Link]("__________________________ ");
[Link]("No. of Days \t\t Rate of Interest ");
[Link]("Up to 180 days \t\t\t\t5.5% ");
[Link]("181 to 364 days \t\t\t\t7.5% ");
[Link]("Exact 365 days \t\t\t\t9.0% ");
[Link]("More than 365 days \t\t\t\t 8.5% ");
[Link]();

[Link]("Enter deposited amount: ");


sum = [Link]();

[Link]("Enter number of days: ");


days = [Link]();

if(days <= 180)


{
rate = 5.5;
}
else if(days >= 181 && days <= 364)
{
rate = 7.5;
}
else if(days == 365)
{
rate = 9.0;
}
else
{
rate = 8.5;
}
interest = (sum * rate * days) / (100 * 365);
maturity = sum + interest;
[Link]("Rate of Interest = " + rate + "%");
[Link]("Interest = Rs. " + interest);
[Link]("Maturity Amount = Rs. " + maturity);
}
}
Output for program 3
Code for program 4
import [Link].*;

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

int a, b, c, second;

[Link]("Enter first number: ");


a = [Link]();

[Link]("Enter second number: ");


b = [Link]();

[Link]("Enter third number: ");


c = [Link]();

second = a + b + c - [Link](a, [Link](b, c))


- [Link](a, [Link](b, c));

[Link]("Second Smallest Number = " + second);


}
}
Output for program 4
Code for program 5
import [Link].*;
class proj_5
{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);

int n, posCount = 0, negCount = 0;


int posSum = 0, negSum = 0;

[Link]("Enter 20 numbers: ");

for(int i = 1; i <= 20; i++)


{
n = [Link]();

if(n > 0)
{
posCount++;
posSum += n;
}
else if(n < 0)
{
negCount++;
negSum += n;
}
}

[Link]("Count of Positive Numbers = " + posCount);


[Link]("Count of Negative Numbers = " + negCount);
[Link]("Sum of Positive Numbers = " + posSum);
[Link]("Sum of Negative Numbers = " + negSum);
}
}
Output for program 5
Code for program 6
import [Link].*;

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

int n, digit, newNum = 0, place = 1;

[Link]("Enter a number: ");


n = [Link]();

while(n > 0)
{
digit = n % 10;

if(digit != 0)
{
newNum = newNum + (digit * place);
place = place * 10;
}

n = n / 10;
}

[Link]("Number after removing zeros = " + newNum);


}
}
Output for program 6
Code for program 7

import [Link].*;

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

int num, digit1, digit2, sum, product, result;

[Link]("Enter a two-digit number: ");


num = [Link]();

digit1 = num / 10;


digit2 = num % 10;

sum = digit1 + digit2;


product = digit1 * digit2;

result = sum + product;

if(result == num)
{
[Link]("Special two-digit number");
}
else
{
[Link]("Not a special two-digit number");
}
}
}
Output for program 7
Code for program 8

import [Link].*;

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

int choice, n, term = 0;


double sum = 0;
int a = 2;

[Link]("MENU");
[Link]("1. Sum of the series");
[Link]("2. Display the series 1, 11, 111...");
[Link]("3. Display Pattern");
[Link]("Enter your choice: ");
choice = [Link]();

switch(choice)
{
case 1:
for(int i = 1; i <= 10; i++)
{
sum = sum + ([Link](a, 2) / i);
}

[Link]("Sum of the series = " + sum);


break;

case 2:
[Link]("Enter value of n: ");
n = [Link]();

for(int i = 1; i <= n; i++)


{
term = term * 10 + 1;
[Link](term + " ");
}
break;

case 3:
for(int i = 1; i <= 5; i++)
{
for(int j = 1; j <= i; j++)
{
Code for program 8

if(j % 2 == 1)
[Link]("* ");
else
[Link]("# ");
}

[Link]();
}
break;

default:
[Link]("Invalid Choice");
}
}
}
Output for program 8
Code for program 9
import [Link].*;

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

int choice, num, sum = 0, digit, temp, square, count = 0;


int divisor = 1;

[Link]("MENU");
[Link]("1. Sum of digits");
[Link]("2. Check Automorphic Number");
[Link]("Enter your choice: ");
choice = [Link]();

switch(choice)
{
case 1:
[Link]("Enter a number: ");
num = [Link]();

temp = num;

while(temp > 0)
{
digit = temp % 10;
sum = sum + digit;
temp = temp / 10;
}

[Link]("Sum of the digits = " + sum);


break;

case 2:
[Link]("Enter a number: ");
num = [Link]();

temp = num;
square = num * num;

while(temp > 0)
{
count++;
temp = temp / 10;
}
Code for program 9

divisor = (int)[Link](10, count);

if(square % divisor == num)


{
[Link](num + " is an Automorphic Number");
}
else
{
[Link](num + " is not an Automorphic Number");
}
break;

default:
[Link]("Invalid Choice");
}
}
}
Output for program 9
Code for program 10

import [Link];

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

int choice, num, temp, digit, rev = 0;


int sum = 0;

[Link]("MENU");
[Link]("1. Check Palindrome Number");
[Link]("2. Check Perfect Number");
[Link]("Enter your choice: ");
choice = [Link]();

switch(choice)
{
case 1:
[Link]("Enter a number: ");
num = [Link]();

temp = num;

while(temp > 0)
{
digit = temp % 10;
rev = rev * 10 + digit;
temp = temp / 10;
}

if(rev == num)
{
[Link](num + " is a Palindrome Number");
}
else
{
[Link](num + " is not a Palindrome Number");
}
break;

case 2:
[Link]("Enter a number: ");
num = [Link]();
Code for program 10

for(int i = 1; i < num; i++)


{
if(num % i == 0)
{
sum = sum + i;
}
}

if(sum == num)
{
[Link](num + " is a Perfect Number");
}
else
{
[Link](num + " is not a Perfect Number");
}
break;

default:
[Link]("Invalid Choice");
}
}
}
Output for program 10

You might also like