0% found this document useful (0 votes)
6 views14 pages

Computer Project

The document is a project for Class IX Computer Applications at Assembly of God Church School, Asansol, covering Java programming topics including conditional constructs and iterative constructs. It contains various Java programs demonstrating decision-making statements, loops, and other programming concepts. Each section includes multiple questions with code examples and explanations.

Uploaded by

hkschool999
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)
6 views14 pages

Computer Project

The document is a project for Class IX Computer Applications at Assembly of God Church School, Asansol, covering Java programming topics including conditional constructs and iterative constructs. It contains various Java programs demonstrating decision-making statements, loops, and other programming concepts. Each section includes multiple questions with code examples and explanations.

Uploaded by

hkschool999
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/ 14

ASSEMBLY OF GOD CHURCH SCHOOL ASANSOL

ICSE COMPUTER APPLICATIONS PROJECT


CLASS IX
2024 - 2025

Topic –
1. Ch – 8 (CONDITIONAL CONSTRUCTS IN JAVA –
DECISION MAKING STATEMENTS)
 Programs 9 – 22

2. Ch – 9 (ITERATIVE CONSTRUCTS IN JAVA – LOOPS OR


ITERATION)
 Programs 17– 27

NAME- HRIDDHIMA KUNDU


CLASS – IX
SEC – B
ROLL NO. 24
SUBJECT – COMPUTER APPLICATIONS
Ch – 8 (CONDITIONAL CONSTRUCTS IN JAVA)

QUESTION 9
public class GreatestInteger
{
public static void main(String[] args)
{
int x = 5;
int y = 10;

if(x > y)
{
System.out.println(x + " is greatest integer.");
}
if(y > x)
{
System.out.println(y + " is greatest integer.");
}
else
{
System.out.println("Both integers are equal.");
}
}
}

QUESTION 10
import java.util.*;
public class CharConversion
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a character: ");
char ch = in.next().charAt(0);
char newCh = ch;
if (ch >= 'A' && ch <= 'Z')
{
newCh+=32;
}
else if (ch >= 'a' && ch <= 'z')
{
newCh-=32;
}
System.out.println("Original character: " + ch);
System.out.println("New character: " + newCh);
}
}

QUESTION 11
import java.util.*;
public class FestivalDiscount
{
void Discount (double tCost)
{
double d = 0.0;
if(tCost <= 2000)
{
d = 5.0;
}
else if(tCost > 2000 && tCost <= 5000)
{
d = 25.0;
}
else if (tCost > 5000 && tCost <= 10000)
{
d = 35.0;
}
else
{
d = 50.0;
}
double discount = (d/100.0) * tCost;
double dAmt = tCost - discount;
System.out.println("Total cost before discount: " + tCost);
System.out.println("Amount to be paid after availing discount: " + dAmt);
}
public static void main(String args[])
{
FestivalDiscount dis = new FestivalDiscount();
Scanner in = new Scanner(System.in);
System.out.println("Enter the total cost: ");
double tCost = in.nextDouble();
dis.Discount(tCost);
}
}

QUESTION 12
import java.util.*;
public class Streams {
void Eligibility(int marks) {
System.out.println("Total marks obtained: " + marks);
System.out.print("Stream allotted: ");
if (marks >= 300) {
System.out.print("Science");
} else if (marks >= 200 && marks < 300) {
System.out.print("Commerce");
} else if (marks >= 75 && marks < 200) {
System.out.print("Arts");
} else {
System.out.print("Admission is not granted, you have to appear in a
qualifying examination.");
}
}
public static void main(String[] args) {
Streams s = new Streams();
Scanner in = new Scanner(System.in);
System.out.print("Enter your marks: ");
int marks = in.nextInt();
s.Eligibility(marks);
}
}

QUESTION 13
import java.util.*;

public class TelephoneBill {


double billCalculator(int c) {
double tb = 0.0;
if (c <= 100) {
tb = c * 250;
} else if (c > 100 && c <= 200) {
tb = (100 * 250) + (c - 100) * 60;
} else if (c > 200 && c <= 300) {
tb = (100 * 250) + (100 * 60) + (c - 200) * 50;
} else {
tb = (100 * 250) + (100 * 60) + (100 * 50) + (c - 300) * 40;
}

return tb / 100.0;
}

public static void main(String[] args) {


TelephoneBill obj = new TelephoneBill();
Scanner in = new Scanner(System.in);
System.out.println("Enter the number of calls: ");
int c = in.nextInt();

double amt = obj.billCalculator(c);


System.out.println("Number of calls: " + c);
System.out.println("Total bill amount to be paid: " + amt);
}
}

QUESTION 14
import java.util.*;
public class Amount1
{
double Amount(double P, double n)
{
double r = 0.0, a = 0.0;
if(n < 1)
{
r = 9.0;
}
else if (n >= 1 && n < 2)
{
r = 10.0;
}
else if(n >= 2 && n <= 3)
{
r = 11.0;
}
else
{
r = 12.0;
}
a = P * Math.pow((1 + r/100.0), n);
return a;
}
public static void main(String[] args)
{
Amount1 amt = new Amount1();
Scanner in = new Scanner(System.in);
System.out.println("Enter the principal amount deposited(P): ");
double P = in.nextDouble();
System.out.println("Enter the number of years(n): ");
double n = in.nextDouble();
double newA = amt.Amount(P, n);
System.out.println("Acquired amount by the investors: " + newA);

}
}

QUESTION 15
import java.util.*;

public class Pension {


void calculatePension() {
Scanner in = new Scanner(System.in);
System.out.println("Enter the sex, M for male and F for female: ");
char c = in.next().charAt(0);
int a, amt;

switch (c) {
case 'F':
case 'f':
System.out.println("Enter the age: ");
a = in.nextInt();
if (a > 60 && a <= 65) {
amt = 45;
System.out.println("Weekly pension: " + amt + " rupees");
} else if (a > 65) {
amt = 45 + 25;
System.out.println("Weekly pension: " + amt + " rupees");
} else {
System.out.println("The person is below the pensionable age and thus
cannot be granted pension.");
}
break;

case 'M':
case 'm':
System.out.println("Enter the age: ");
a = in.nextInt();

if (a > 65 && a <= 70) {


amt = 50;
System.out.println("Weekly pension: " + amt + " rupees");
} else if (a > 70) {
amt = 50 + 20;
System.out.println("Weekly pension: " + amt + " rupees");
} else {
System.out.println("The person is below the pensionable age and thus
cannot be granted pension.");
}
break;

default:
System.out.println("Invalid sex entered.");
break;
}
}
public static void main(String[] args) {
Pension pension = new Pension();
pension.calculatePension();
}
}

QUESTION 16
import java.util.*;

public class MathOperations {


int Exponent(int x, int y) {
int expo = (int) Math.pow(x, y);
return expo;
}
int Rectangle(int l, int b) {
int area = l * b;
return area;
}
public static void main(String[] args) {
MathOperations mathOperations = new MathOperations();
Scanner in = new Scanner(System.in);
System.out.println("Enter the value of x and y: ");
int x = in.nextInt();
int y = in.nextInt();
int ex = mathOperations.Exponent(x, y);
System.out.println(x + " raised to the power of " + y + " is " + ex);

System.out.println("Enter the value of l(length) and b(breadth): ");


int l = in.nextInt();
int b = in.nextInt();
int rec = mathOperations.Rectangle(l, b);
System.out.println("The area of the rectangle with length " + l + " and breadth "
+ b + " is " + rec);
}
}

QUESTION 17
int y;
y = (y >= 150)? y * 15 : y - 15;

QUESTION 18
int ch, m;
if(m > 300)
{
ch = (m/10) * 2;
}
else
{
ch = (m/20) - 2;
}

QUESTION 19
char res; int mark;
res = (mark > 300)? 'P' : 'F';

QUESTION 20
int n = 0;
switch(ch)
{
case 1:
n = n + 2;
break;
case 2:
n = n + 4;
break;

case 3:
n = n + 6;
break;

default:
System.out.println("OOPs ! try again");
}

QUESTION 21
int v;
if(v == 1)
{
System.out.println("First");
}
else if(v == 0)
{
System.out.println("Zero");
}
else if(v == -3)
{
System.out.println("Minus Three");
}

QUESTION 22
int v;
if(v == 1)
{
System.out.println("First");
}
else if(v == 0)
{
System.out.println("Zero");
}
else if(v == -3)
{
System.out.println("Minus Three");
}

Ch – 9 (ITERATIVE CONSTRUCTS IN JAVA)


QUESTION 17
import java.util.*;
public class Factor {
void calculateFactors(int num) {
for (int i = 1; i <= num; i++) {
if (num % i == 0) {
System.out.print(i + " ");
}
}
}

public static void main(String[] args) {


Factor factor = new Factor();
Scanner in = new Scanner(System.in);
System.out.println("Enter a number: ");
int num = in.nextInt();
System.out.print("The factors of " + num + " are ");
factor.calculateFactors(num);
}
}

QUESTION 18
import java.util.*;
public class Cubes {
void print()
{
int s = 0, cb = 0;
for(int i = 1; i <= 10; i++ )
{
cb = i * i * i;
System.out.print(cb + " ");
s+= i * i * i;
}
System.out.println();
System.out.println("The sum of the cubes of numbers 1 to 10 are " + s);
}

public static void main(String[] args) {


Cubes cube = new Cubes();
Scanner in = new Scanner(System.in);
System.out.print("The cubes of nnumbers 1 to 10 are ");
cube.print();
}
}

QUESTION 19
import java.util.*;

public class FactorProduct {


void productOfFactors(int N) {
int i = 1, f = 1;
System.out.println("The product of the factors of " + N + " is: ");
do {
if (N % i == 0) {
f *= i;
if (i == N)
{
System.out.print(i);
break;
}
System.out.print(i + "X");
}
i++;
} while (i <= N);
System.out.print(" = " + f);
}

public static void main(String[] args) {


FactorProduct factorProduct = new FactorProduct();
Scanner in = new Scanner(System.in);
System.out.println("Enter a number:");
int N = in.nextInt();
factorProduct.productOfFactors(N);
}
}

QUESTION 20
import java.util.*;
public class Even_Sum {
void Even() {
int i = 2, s = 0;
while(i < 40) {
if(i % 2 == 0) {
s+= i;
}
i++;
}
System.out.print("The sum of all the even numbers between 1 and 40 is " + s);
}
public static void main(String[] args) {
Even_Sum evenSum = new Even_Sum();
Scanner in = new Scanner(System.in);
evenSum.Even();
}
}

QUESTION 21
import java.util.*;
public class OddSum {
void Odd() {
int i = 2, s = 0;
while (i < 40) {
if (i % 2!= 0) {
s += i;
}
i++;
}
System.out.print("The sum of all the odd numbers between 1 and 40 is " + s);
}
public static void main(String[] args) {
OddSum oddSum = new OddSum();
oddSum.Odd();
}
}
QUESTION 22
import java.util.*;
public class Factorial1 {
void Factorial(int n) {
int f = 1;
for (int i = 1; i <= n; i++) {
f *= i;
if (i == n) {
System.out.print(i);
break;
}
System.out.print(i + "X");
}
System.out.print(" or ");
for (int i = n; i >= 1; i--) {
if (i == 1) {
System.out.print(i);
break;
}
System.out.print(i + "X");
}
System.out.print(" = " + f);
}

public static void main(String[] args) {


Factorial1 fac = new Factorial1();
Scanner in = new Scanner(System.in);
System.out.println("Enter a number to print its factorial: ");
int n = in.nextInt();
System.out.print("The factorial of (" + n + "!) is ");
fac.Factorial(n);
}
}

QUESTION 23
public class Capital_letters
{
public static void main(String[] args)
{
char i;
System.out.println("All capital letters from A to Z are: ");
for(i = 'A'; i <= 'Z'; i++)
{
System.out.print(i + " ");
}
}
}

QUESTION 24
import java.util.*;
public class Prime {
void findPrime(int N) {
if (N == 1) {
System.out.println(N + " is not a prime number.");
return;
}
int c = 0;
for (int i = 2; i < N; i++) {
if (N % i == 0) {
c++;
}
}
if (c == 0) {
System.out.println(N + " is a prime number.");
} else {
System.out.println(N + " is not a prime number.");
}
}

public static void main(String[] args) {


Prime prime = new Prime();
Scanner in = new Scanner(System.in);
System.out.println("Enter a number: ");
int N = in.nextInt();
prime.findPrime(N);
}
}

QUESTION 25
import java.util.*;
public class Perfect {
void findPerfect(int N) {
int s = 0;
System.out.print("Factors of " + N + " excluding itself are: ");
boolean firstFactor = true;
for (int i = 1; i < N; i++) {
if (N % i == 0) {
if (!firstFactor) {
System.out.print(" + ");
}
System.out.print(i);
s += i;
firstFactor = false;
}
}

System.out.println(" = " + s);


if (s == N) {
System.out.println("Thus " + N + " is a perfect number because the sum of its
factors excluding " + N + " is equal to " + N);
} else {
System.out.println("Thus " + N + " is not a perfect number because the sum
of its factors excluding " + N + " is not equal to " + N);
}
}

public static void main(String[] args) {


Perfect perfect = new Perfect();
Scanner in = new Scanner(System.in);
System.out.println("Enter a number to check if it is a perfect number or not: ");
int N = in.nextInt();
perfect.findPerfect(N);
}
}

QUESTION 26
import java.util.*;
public class SumOfSeries {
void Sum(int x, int n) {
int s = 0;
System.out.println("The sum of the series is as follows: ");
for(int i = 0; i <= n; i+=2) {
if(i == n) {
System.out.print(x + "^" + i);
s+= (int) Math.pow(x, i);
break;
}
System.out.print(x + "^" + i + " + ");
s+= (int) Math.pow(x, i);
}
System.out.println(" = " + s);
}
public static void main(String[] args) {
SumOfSeries sumOfSeries = new SumOfSeries();
Scanner in = new Scanner(System.in);
System.out.println("Enter the value of x: ");
int x = in.nextInt();
System.out.println("Enter the value of n: ");
int n = in.nextInt();
sumOfSeries.Sum(x, n);
}
}

QUESTION 27
import java.util.*;
public class Series12 {
void Sum1() {
int series;
System.out.println("The required series upto 12 terms is as follows: ");
for(int i = 1; i <= 12; i++) {
series = (i * i) - 1;
if(i == 12) {
System.out.print(series);
break;
}
System.out.print(series + ", ");
}
}
public static void main(String[] args) {
Series12 s = new Series12();
Scanner in = new Scanner(System.in);
s.Sum1();
}
}

***********

You might also like