Computer Project
2024-2025
Name: Lohitaksh
Class: IX A DS
St. ID: 13-0013
Program:
import [Link];
public class EmployeeWages {
public static void main(String[] args) {
Scanner = new Scanner([Link]);
[Link]("Enter the number of hours worked: ");
int hoursWorked = [Link]();
[Link]("Enter the total sales: ");
double totalSales = [Link]();
double hourlyWage = 500;
double commissionRate = 0;
if (totalSales >= 100 && totalSales < 1000) {
commissionRate = 0.01; // 1%
} else if (totalSales >= 1000 && totalSales < 10000) {
commissionRate = 0.02; // 2%
} else if (totalSales >= 10000 && totalSales < 25000) {
commissionRate = 0.03; // 3%
} else if (totalSales >= 25000) {
commissionRate = 0.035; // 3.5%
}
double baseWage = hoursWorked * hourlyWage;
double commission = totalSales * commissionRate;
double totalWage = baseWage + commission;
[Link]("Base wage: Rs. " + baseWage);
[Link]("Commission: Rs. " + commission);
[Link]("Total wage: Rs. " + totalWage);
}
}
Program:
import [Link];
public class ParcelChargeCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter the weight of the parcel in Kg: ");
double weight = [Link]();
double totalCharge = 0;
if (weight <= 10) {
totalCharge = weight * 30;
} else if (weight <= 30) {
totalCharge = (10 * 30) + (weight - 10) * 20;
} else {
totalCharge = (10 * 30) + (20 * 20) + (weight - 30) * 15;
}
[Link]("Total charge for a parcel of %.2f Kg is Rs. %.2f\n", weight, totalCharge);
}
}
Program:
import [Link];
class ZenixMall {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("\n--- Zenix Mall ---");
[Link]("Enter code for an item:");
[Link]("L = Laptop (5% discount)");
[Link]("D = LCD (7% discount)");
[Link]("X = XBox (10% discount)");
[Link]("P = Printer (11% discount)");
[Link]("Enter your choice: ");
char choice = [Link]().charAt(0);
double price, discount = 0, totalAmount;
switch (choice) {
case 'L': // Laptop
[Link]("Enter price of Laptop: ");
price = [Link]();
discount = 5;
totalAmount = price - (price * discount / 100);
[Link]("Total amount to pay after " + discount + "% discount: " + totalAmount);
break;
case 'D': // LCD
[Link]("Enter price of LCD: ");
price = [Link]();
discount = 7;
totalAmount = price - (price * discount / 100);
[Link]("Total amount to pay after " + discount + "% discount: " + totalAmount);
break;
case 'X': // XBox
[Link]("Enter price of XBox: ");
price = [Link]();
discount = 10;
totalAmount = price - (price * discount / 100);
[Link]("Total amount to pay after " + discount + "% discount: " + totalAmount);
break;
case 'P': // Printer
[Link]("Enter price of Printer: ");
price = [Link]();
discount = 11;
totalAmount = price - (price * discount / 100);
[Link]("Total amount to pay after " + discount + "% discount: " + totalAmount);
break;
default:
[Link]("Invalid choice!");
break;
}
}
}
Program:
import [Link];
public class ElectricityBillCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter the units consumed: ");
int unitsConsumed = [Link]();
double billAmount = 0;
int serviceCharge = 200;
if (unitsConsumed <= 100)
billAmount = unitsConsumed * 2.0;
else if (unitsConsumed <= 200)
billAmount = unitsConsumed* 2.5;
else
billAmount = unitsConsumed * 3.0;
billAmount += serviceCharge;
[Link]("Total Bill: ₹ " + billAmount);
}
}
Program:
import [Link];
public class TimeConversion {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
int choice;
double input, result;
[Link]("Choose a conversion option:");
[Link]("1. Milliseconds to Seconds");
[Link]("2. Milliseconds to Minutes");
[Link]("3. Seconds to Milliseconds");
[Link]("4. Seconds to Minutes");
[Link]("5. Minutes to Milliseconds");
[Link]("6. Minutes to Seconds");
[Link]("Enter your choice: ");
choice = [Link]();
[Link]("Enter the value to convert: ");
input = [Link]();
switch (choice) {
case 1:
result = input / 1000;
[Link](input + " milliseconds = " + result + " seconds");
break;
case 2:
result = input / (1000 * 60);
[Link](input + " milliseconds = " + result + " minutes");
break;
case 3:
result = input * 1000;
[Link](input + " seconds = " + result + " milliseconds");
break;
case 4:
result = input / 60;
[Link](input + " seconds = " + result + " minutes");
break;
case 5:
result = input * 60000;
[Link](input + " minutes = " + result + " milliseconds");
break;
case 6:
result = input * 60;
[Link](input + " minutes = " + result + " seconds");
break;
default:
[Link]("Invalid choice! Please select a number between 1 and 6.");
}
}
}
Program:
import [Link];
public class SeriesProgram {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
int choice;
[Link]("1. Calculate the sum of the series S = 0 + 3 + 8 + 15 + 24 + ... up to n terms");
[Link]("2. Print the series: 1 -3 5 -7 ... (first 10 terms)");
[Link]("Enter your choice: ");
choice = [Link]();
switch (choice) {
case 1:
[Link]("Enter the number of terms (n): ");
int n = [Link]();
int sum = 0;
for (int i = 1; i <= n; i++) {
int term = i * i - 1;
sum += term;
}
[Link]("Sum of the series up to " + n + " terms is: " + sum);
break;
case 2:
int k = 1;
for (int i = 0; i < 10; i += 1) {
int term = (int) (k * [Link](-1, i));
k += 2;
[Link](term + " ");
}
break;
default:
[Link]("Invalid choice. Please try again.");
}
}
}
7. Write a menu driven program to accept a number from the user and check whether
a. it is a ‘BUZZ’ number
b. to accept any two numbers and print the ‘GCD’ of them.
(a) A BUZZ number is the number which either ends with 7 or divisible by 7. (b) GCD (Greatest Common Divisor) of
two integers is calculated by continued
division method. Divide the larger number by the smaller; the remainder then divides the previous divisor. The
process is repeated till the remainder is zero. The divisor then results the GCD.
Program:
import [Link];
public class BuzzGCD{
public static void main(String[] args){
Scanner sc = new Scanner([Link]);
[Link]("a = Check whether it is a buzz number");
[Link]("b = Calculate gcd");
[Link]("Enter choice");
char ch = [Link]().charAt(0);
switch(ch) {
case 'a':
[Link]("Enter the number:");
int num1 = [Link]();
if (num1 % 7 == 0 || num1 % 10 == 7)
[Link]("It is a Buzz number");
else
[Link]("It is not a Buzz number");
break;
case 'b':
[Link]("Enter Two Numbers");
int num2 = [Link]();
int num3 = [Link]();
while (num2 % num3 != 0) {
int r = num2 % num3;
num2 = num3;
num3 = r;
}
[Link]("GCD is :" + num3);
break;
default:
[Link]("Invalid choice!");
}
}
}
import [Link];
public class Series{
public static void main(String[] args){
Scanner sc = new Scanner([Link]);
double a=0, b=1, s=0;
[Link]("Enter a number:");
int n = [Link]();
for(int i=1; i<=n; i+=1){
a+=i;
b*=i;
s+=(a/b);
}
[Link]("the sum of the series is: "+s);
}
}
9. Write a program to compute and display the sum of the following series:
S = 1/a + 1/a2 + 1/a3 + ...... + 1/an
Program:
import [Link];
public class GP {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter the value of a (non-zero): ");
double a = [Link]();
[Link]("Enter the value of n (positive integer): ");
int n = [Link]();
if (a == 0) {
[Link]("Division by zero is not allowed.");
}
double S = 0.0;
for (int i = 1; i <= n; i++) {
S += 1 / [Link](a, i);
}
[Link]("The sum of the series S = 1/a + 1/a^2 + ... + 1/a^n is: "+ S);
}
}
10. Write a program to compute and display the sum of the following series:
S= 1+ 1/ 2 ! + 1 / 3 ! + 1 / 4 ! + ---------------------------- --+ 1/ n !
Programs:
import [Link];
public class SeriesSum{
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter the value of n: ");
int n = [Link]();
double sum=0;
for (int i = 1; i <= n; i++) {
double fact = 1;
for (int j = 1; j <= i; j++) {
fact *= j;
}
sum += 1.0 / fact;
}
[Link]("The sum of the series is:" + sum);
}
}