[go: up one dir, main page]

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

Comppro

Uploaded by

r29110157
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)
11 views10 pages

Comppro

Uploaded by

r29110157
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
You are on page 1/ 10

import java.util.

*;

class Armstrong {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter the number");

int n = sc.nextInt();

int s = 0;

int c = n;

while (n > 0) {

int r = n % 10;

s = s + (r * r * r);

n = n / 10;

if (s == c){

System.out.println("Armstrong");

}else{
System.out.println("Not Armstrong");

import java.util.Scanner;

public class GradingSystem {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter your marks: ");

int marks = scanner.nextInt();

char grade = calculateGrade(marks);

System.out.println("Your grade is: " + grade);

public static char calculateGrade(int marks) {

if (marks >= 90) {


return 'A';

} else if (marks >= 75) {

return 'B';

} else if (marks >= 60) {

return 'C';

} else if (marks >= 50) {

return 'D';

} else {

return 'F';

import java.util.Scanner;

public class ElectricityBillCalculator {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter the number of units


consumed: ");

int units = scanner.nextInt();


double bill = calculateBill(units);

System.out.println("Your electricity bill is: " +


bill);

public static double calculateBill(int units) {

double bill = 0;

if (units <= 100) {

bill = units * 1.5;

} else if (units <= 300) {

bill = 100 * 1.5 + (units - 100) * 2.0;

} else if (units <= 500) {

bill = 100 * 1.5 + 200 * 2.0 + (units - 300) * 3.0;

} else {

bill = 100 * 1.5 + 200 * 2.0 + 200 * 3.0 + (units -


500) * 5.0;

return bill;

}
}

import java.util.Scanner;

public class IncomeTaxCalculator {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter your annual income: ");

double income = scanner.nextDouble();

double tax = calculateTax(income);

System.out.println("Your income tax is: " + tax);

public static double calculateTax(double income) {

double tax = 0;

if (income <= 250000) {

tax = 0;

} else if (income <= 500000) {


tax = (income - 250000) * 0.05;

} else if (income <= 1000000) {

tax = (income - 500000) * 0.2 + 250000 * 0.05;

} else {

tax = (income - 1000000) * 0.3 + 500000 * 0.2 +


250000 * 0.05;

return tax;

import java.util.*;

class Check {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter the number");

int n = sc.nextInt();

if (n % 4 == 0) {

System.out.println("Leap year");

} else {

System.out.println("Not a leap year");

}
}

import java.util.*;

class Check {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter the cost price and


selling price");

int cp = sc.nextInt();

int sp = sc.nextInt();

if (sp > cp) {

System.out.println("Profit");

} else {

System.out.println("Loss");

import java.util.Scanner;
class Sum {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int sum = 0;

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

sum = sum + i;

System.out.println("Result is: " + sum);

import java.util.*;

class Check {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter the number");

int n = sc.nextInt();

if (n%6 == 0) {

System.out.println("Multiple of 6");

} else {
System.out.println("Not a multiple of 6");

import java.util.*;

class sum {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int s = 0;

for (int i = 50; i <= 100; i+= 2) {

s = s + i;

System.out.println("Result is " + s);

import java.util.*;

class Check {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);


System.out.println("Enter the number");

int a = sc.nextInt();

if (a % 3 == 0) {

System.out.println("Divisible");

} else {

System.out.println("Not divisible");

You might also like