Holiday Homework
Holiday Homework
2024-25
YEAR 2024-25
JAVA NETBEANS
PRINCIPAL
Acknowledgement
OUTPUT
3. Program to print Simple Interest, Principle, Rate of Interest and Time is user
given value.
public class INTREST {
public static void main(String[] args)
{
System.out.println("Insert value");
int p=5000;
int t=3;
float R=0.2f;
float si=(p*t*R)/100;
System.out.println("Result="+si);
}}
OUTPUT
10. Program to print the number 1 to 10 by the help of for loop in Java
Programming. Use of “\t” (to insert tab space)
public class counting {
public static void main(String[] args)
{
for(int i=1;i<=10;i++)
{
System.out.print(i+"\t");
}
}
}
OUTPUT:
11. Program to print a pattern with the help of for loop in nested condition.
public class pattern {
public static void main(String[] args)
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print("* ");
}
System.out.println();
}
}}
OUTPUT:
12. Program to print the number between 1 to 10. By the help of while loop in
Java Programming.
public class count
{
public static void main(String[] args)
{
int number = 1;
while (number <= 10)
{
System.out.print(number+"\t");
number++;
}
}
} OUTPUT
14. Program to print the reverse counting with the help of while loop.
public class revcounting{
public static void main(String[] args){
int number = 5;
while (number >= 1)
{
System.out.println (number);
number--;
}
}
}
OUTPUT:
15. Program to print the square of given number with the of do-while loop.
public class Nsquare
{
public static void main(String[] args){
int number = 1;
do {
System.out.print ("Square of " + number);
System.out.println (" = " + number*number);
++number;
} while (number <= 5);
}
}
OUTPUT:
20. Program to use an array to print class report card for five students.
public class Arrays {
public static void main(String[] args) {
double[]marks = {346, 144, 103, 256.5, 387.5};
double total_marks=400;
for (int i = 0; i <marks.length; i++){
double percentage = (marks[i]/total_marks)*100;
String result;
if (percentage >= 40)
result = "Passed";
else
result = "Failed";
System.out.print((i+1)+"\t");
System.out.print(marks[i]+"\t");
System.out.print(percentage+"\t\t");
System.out.println(result);
}
}
}
OUTPUT:
21. Program to make user defined class in Java Programming.
public class Jvclass {
String title;
String publisher;
String author;
double price;
void display(){
System.out.println("Title="+title);
System.out.println("Author="+author);
System.out.println("Publisher="+publisher);
System.out.println("Price="+price);}
public static void main(String[] args) {
Jvclass obj=new Jvclass();
obj.title="Game of Thrones";
obj.author="Harper Collins";
obj.publisher="George R Martin";
obj.price=450.0;
obj.display();
}
}
OUTPUT:
}}
OUTPUT: