[Go to site: main page, start]

0% found this document useful (0 votes)
16 views3 pages

Java Programs for Beginners: Basics & I/O

Uploaded by

krishnasahoo4243
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)
16 views3 pages

Java Programs for Beginners: Basics & I/O

Uploaded by

krishnasahoo4243
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

Java Program

1.​ WAP to print "Hello World".


/**​
* Write a description of class HelloWorld here.​
*​
* @author (your name)​
* @version (a version number or a date)​
*/​
public class HelloWorld​
{​
public static void main(String args[]){​
// [Link](args[0]);​
[Link]("Hello World");​
}​
}
2.​ WAP to display your biodata as output.
/**​
* Write a description of class BioData here.​
* Student will print their name, address, class and Subject combination​
*​
* @author (your name)​
* @version (a version number or a date)​
*/​
public class BioData​
{​
public static void main(String args[]){​
[Link]("***** BIO DATA ******");​
[Link]("Name: Sanket Kumar Panda");​
[Link]("Address: Jaharitoli, Nuagaon, Sundergarh");​
[Link]("Class: XII");​
[Link]("Subject: Phy, Chem, Math, Bio, IT, Eng,
Physical");​
}​
}
3.​ WAP to take a value as user input, store it in a variable and display the value of
variable as output.
/**​
* Write a description of class ProgramThree here.​
* WAP to take a value as user input, store it in a​
* variable and display the value of variable as​
* output.​
*​
* @author (your name)​
* @version (a version number or a date)​
*/​
import [Link];​
public class ProgramThree​
{​
public static void main(String args[]){​
// Creating Scanner Object for taking user input​
Scanner sc = new Scanner([Link]);​
[Link]("Enter the name");​
// Taking the user input in name variable​
String name = [Link]();​
// Printing the contents of name variable ​
[Link]("Good morning! "+name);​
}​
}
4.​ WAP to find the sum of two numbers.
/**​
* Write a description of class ProgramFour here.​
* WAP to find the sum of two numbers.​
* @author (your name)​
* @version (a version number or a date)​
*/​
import [Link];​
public class ProgramFour​
{​
public static void main(String args[]){​
// Create Scanner Object​
Scanner sc = new Scanner([Link]);​
// Taking the user input in a​
int a = [Link]();​
// Taking the user input in b​
int b = [Link]();​
// Calculate the sum and store in result variable​
int result = a + b;​
// Print the result ​
[Link]("Sum of " + a + " and " + b + " is equal to "
+ result);​

}​
}
5.​ WAP to find the quotient of two numbers when divided.
/**​
* Write a description of class ProgramFive here.​
* WAP to find the quotient of two numbers when​
* divided.​
*​
* @author (your name)​
* @version (a version number or a date)​
*/​
public class ProgramFive​
{​
public static void main(String args[]){​
// Initialise the variable a​
int a = 20;​
// Initialise the variable b​
int b = 5;​
// Find the quotient​
int q = a/b;​
// Print the quotient​
[Link]("Quotient of " + a + " division " + b + " is
equal to " + q);​
}​
}
8. WAP to calculate the Compound Interest by taking user input.
/**​
* Write a description of class ProgramEight here.​
* WAP to calculate the Compound Interest by taking user input.​
*​
* @author (your name)​
* @version (a version number or a date)​
*/​
import [Link];​
import [Link];​
public class ProgramEight​
{​
public static void main(String args[]){​
Scanner sc = new Scanner([Link]);​
double p = [Link]();​
double r = [Link]();​
double n = [Link]();​
double interest = p * [Link]((1+r/100),n) - p;​
[Link]("CI: " + interest);​
}​
}
Exercise ​
6. WAP to find the remainder of two numbers when divided.(Use % operator)
7. WAP to calculate the Simple Interest by taking Principal amount, Rate of Interest and
Time as user Input.

You might also like