[Go to site: main page, start]

0% found this document useful (0 votes)
49 views5 pages

Java Programs for Beginners

The document presents three Java programs: a Month Printer that outputs the month name based on user input, a Four Numbers Equality checker that determines if four predefined numbers are equal, and a Salary Tax Calculator that computes tax based on user-entered salary. Each program includes necessary imports, user input handling, and output statements. The document is intended for an introductory information technology course.

Uploaded by

muqadas.hafiz07
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)
49 views5 pages

Java Programs for Beginners

The document presents three Java programs: a Month Printer that outputs the month name based on user input, a Four Numbers Equality checker that determines if four predefined numbers are equal, and a Salary Tax Calculator that computes tax based on user-entered salary. Each program includes necessary imports, user input handling, and output statements. The document is intended for an introductory information technology course.

Uploaded by

muqadas.hafiz07
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

Name: Monaza Hafiz

Introduction to information technology


Instructor: Asadullah Jalali
Date: Dec 17, 2025
Title: Java Program

1: Month Printer Program:


import [Link];
public class MonthPrinter {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter a number (1-12): ");
int month = [Link]();

switch (month) {
case 1:
[Link]("January");
break;
case 2:
[Link]("February");
break;
case 3:
[Link]("March");
break;
case 4:
[Link]("April");
break;
case 5:
[Link]("May");
break;
case 6:
[Link]("June");
break;
case 7:
[Link]("July");
break;
case 8:
[Link]("August");
break;
case 9:
[Link]("September");
break;
case 10:
[Link]("October");
break;
case 11:
[Link]("November");
break;
case 12:
[Link]("December");
break;
default:
[Link]("Invalid input");
}
[Link]();
}
}

2: Four Numbers Equality check:


public class FourNumbersEquality {
public static void main(String[] args) {
int num1 = 12;
int num2 = 12;
int num3 = 12;
int num4 = 12;

if (num1 == num2) {
if (num2 == num3) {
if (num3 == num4) {
[Link]("All four numbers are equal");
} else {
[Link]("Not equal");
}
} else {
[Link]("Not equal");
}
} else {
[Link]("Not equal");
}
}
}
3: Java salary tax calculator:
import [Link];
public class SalaryTaxCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter your salary: ");
double salary = [Link]();
double tax = 0;

if (salary > 100000) {


tax = salary * 0.10;
} else if (salary > 50000) {
tax = salary * 0.05;
} else if (salary > 20000) {
tax = salary * 0.025;
} else if (salary > 10000) {
tax = salary * 0.01;
} else {
tax = 0;
}

if (tax < 10000) {


tax = 0;
}

[Link]("Salary: " + salary);


[Link]("Tax: " + tax);
[Link]();
}
}

You might also like