Practice Programs for Java


  •   Write a program and simple display  “Helo world……My name is Ali Haider” (by System.out.print statement )
  • Write a program that get your roll number and then display it on the screen. (by System.out.print statement & int n=input.nextInt();)
  •   Write a program that get input from user in two variables and program show sum, subtraction, multiply and divide of these two values. (by variables)
  •   Write a program for ABC bank system; user ask to enter the amount to deposit in saving account, number of year for save the amount and interest rate in percentage. Program should display the the net amount after given number of year. (simple arithmtic operator)
  •   Write a program that ask from user to enter two numbers in to different variable and then the program decide and show that which value is greater.(by if statement)
  •   Write a program that swap the value; such that user enter two integre values in two different variables and then swap the value of variables.  (by the third variable)


                                                 The output should be like that;
Int a=10;
Int b=20;         
After swap the value change like this :
Int a=20;
Int b=10;

  •   Write a program that take input of three variable and program decide that which one is greatest, which one is smallest and which is in between them.(by if else statement)

  •   Write a program that user enter the number of sny subject and prorgam should display the  display the grade for given critaria: (by if else if statement)


100 to 70       A+
69 to 60         A
59 to 50         B
49 to 40         C
39 to 30         E
Less than 30  F


  •   Write a program that ask the user to enter the character, and program display message according to the chart:
Character
Message ; output
L
Lahore, Lahore is the Capital of Punjab.
K
Karachi, Karachi is the Capital of Sinth.
Q
Quetta, Quetta is the Capital of Balochistan.
P
Pashawer, Pashawer is the Capital of KPK.
G
Gilgit, Gilgit is the Capital of Gilgitbulistan

(by switch struction)

  • Write a program which display multiplicative table of entered number upto 100.(by while loop)

  • Write a program that display “I love Pakistan” in this way; (by for loop)

I love Pakistan
                                I love Pakistan
                                                                I love Pakistan
                                                                                                I love Pakistan
                                                                                                                                I love Pakistan

Comments

Popular posts from this blog

Operating System | Best Definition of Opetating System

Umbrella activities in Software Engineering