0% found this document useful (0 votes)
9 views10 pages

Computer Program NB

The document contains Java solutions for various programming problems assigned as holiday homework for Class 10 Computer Applications. Each program includes a variable description table detailing the data types and purposes of the variables used. The programs cover topics such as series generation, factorial sums, digit reversal, product series, electricity billing, and sales commission calculations.

Uploaded by

sukritsingh984
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)
9 views10 pages

Computer Program NB

The document contains Java solutions for various programming problems assigned as holiday homework for Class 10 Computer Applications. Each program includes a variable description table detailing the data types and purposes of the variables used. The programs cover topics such as series generation, factorial sums, digit reversal, product series, electricity billing, and sales commission calculations.

Uploaded by

sukritsingh984
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

Here are the text-based Java solutions for the Holiday Homework (Class 10 Computer

Applications) with variable description tables after each one, and no comments inside the
code as requested:

Program 1: Series – 1 3, 2 6, 3 9, …, 10 30

Public class SeriesOne {

Public static void main(String[] args) {

For (int I = 1; I <= 10; i++) {

System.out.println(I + “ “ + (I * 3));

Variable Description Table:

Variable Data Type Description

I int Loop counter from 1 to 10

Program 2: Series – 2 4, 4 6, 6 8, …, 10 12
Public class SeriesTwo {

Public static void main(String[] args) {

For (int I = 2; I <= 10; I += 2) {

System.out.println(I + “ “ + (I + 2));

Variable Description Table:

Variable Data Type Description

I int Loop counter from 2 to 10 (even numbers)

Program 3: S = 1 + (1×2) + (1×2×3) + … + (1×2×…×5)

Public class SeriesFactorialSum {

Public static void main(String[] args) {

Int sum = 0;

Int fact = 1;

For (int I = 1; I <= 5; i++) {

Fact *= I;
Sum += fact;

System.out.println(“Sum = “ + sum);

Variable Description Table:

Variable Data Type Description

Sum int Holds the sum of the factorial terms

Fact int Stores the intermediate factorial

I int Loop counter from 1 to 5

Program 4: Reverse digits with comma

Import java.util.Scanner;

Public class ReverseDigits {

Public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print(“Enter a number: “);

Int n = sc.nextInt();
While (n > 0) {

Int d = n % 10;

System.out.print(d);

N /= 10;

If (n > 0) {

System.out.print(“,”);

Variable Description Table:

Variable Data Type Description

Sc Scanner To take user input

N int Stores input number

D int Extracted digit in reverse order

Program 5: P = (x+1)(x+3)(x+5)…(x+n)

Import java.util.Scanner;
Public class ProductSeries {

Public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print(“Enter x: “);

Int x = sc.nextInt();

System.out.print(“Enter n: “);

Int n = sc.nextInt();

Int product = 1;

For (int I = 1; I <= n; I += 2) {

Product *= (x + i);

System.out.println(“Product = “ + product);

Variable Description Table:

Variable Data Type Description

Sc Scanner For user input

X int First term in the series

N int Last increment in the series

Product int Stores result of product computation

I int Loop counter from 1 to n, step 2


Program 6: S = (x+x²)/2! + (x+x³)/3! + …

Import java.util.Scanner;

Public class XPowerSeries {

Public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print(“Enter x: “);

Int x = sc.nextInt();

System.out.print(“Enter n: “);

Int n = sc.nextInt();

Double sum = 0;

For (int I = 2; I <= n; i++) {

Int fact = 1;

For (int j = 1; j <= I; j++) {

Fact *= j;

Sum += (double)(x + Math.pow(x, i)) / fact;

System.out.println(“Sum = “ + sum);

Variable Description Table:


Variable Data Type Description

Sc Scanner For user input

X int Base number for the power terms

N int Number of terms to compute

Sum double Accumulated result of the series

I, j int Loop counters for terms and factorial

Fact int Stores factorial of i

Program 7: Electricity bill based on slabs

Import java.util.Scanner;

Public class ElectricityBill {

Public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print(“Enter previous reading: “);

Int prev = sc.nextInt();

System.out.print(“Enter current reading: “);

Int curr = sc.nextInt();

Int units = curr – prev;

Double amount = 0;
If (units <= 100)

Amount = units * 2;

Else if (units <= 250)

Amount = 100 * 2 + (units – 100) * 3.5;

Else if (units <= 650)

Amount = 100 * 2 + 150 * 3.5 + (units – 250) * 5;

Else

Amount = 100 * 2 + 150 * 3.5 + 400 * 5 + (units – 650) * 7.5;

System.out.println(“Total units = “ + units);

System.out.println(“Amount = Rs.” + amount);

Variable Description Table:

Variable Data Type Description

Sc Scanner For user input

Prev int Previous meter reading

Curr int Current meter reading

Units int Units consumed

Amount double Total bill amount calculated


Program 8: Sales commission and gift

Import java.util.Scanner;

Public class SalesCommission {

Public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print(“Enter number of sales: “);

Int sales = sc.nextInt();

System.out.print(“Enter selling amount: “);

Double amount = sc.nextDouble();

Double commission = 0;

String gift = “”;

If (sales <= 50) {

Commission = amount * 0.05;

Gift = “A parker pen”;

} else if (sales <= 75) {

Commission = amount * 0.075;

Gift = “A Micro SD Card”;

} else if (sales <= 100) {

Commission = amount * 0.10;

Gift = “A Mobile”;

} else {

Commission = amount * 0.15;

Gift = “A Laptop”;

}
System.out.println(“Commission = Rs.” + commission);

System.out.println(“Gift = “ + gift);

Variable Description Table:

Variable Data Type Description

Sc Scanner For user input

Sales int Number of products sold

Amount double Total sales amount

Commission double Commission based on sales count

Gift String Gift based on sales tier

Let me know if you want all of these added to a Word or PDF file next!

You might also like