Sie sind auf Seite 1von 13

Programming language

Practical exam 2013 Code: Name:




Write a program to find the output of the arithmetic
operations (+,-,/,*,%) ?

import java.util.Scanner;
Scanner input = new Scanner(System.in);
int x = input.nextInt();
int y = input.nextInt();
System.out.println(x+y);
System.out.println(x-y);
System.out.println(x*y);
System.out.println(x/y);
System.out.println(x%y);
Programming language
Practical exam 2013 Code: Name:
Write a program to calculate of the average of three given
numbers?

import java.util.Scanner;

Scanner input = new Scanner(System.in);
int x = input.nextInt();
int y = input.nextInt();
int z = input.nextInt();
System.out.println((x+y+z)/3);
Programming language
Practical exam 2013 Code: Name:

import java.util.Scanner;
Scanner input = new Scanner(System.in);
int x = input.nextInt();
int y = input.nextInt();
int z = input.nextInt();
System.out.println(((x+y)/(z-y))*(x-y)/y);
Programming language
Practical exam 2013 Code: Name:

Write a java program to find a given number is odd or even?

import java.util.Scanner;
Scanner input = new Scanner(System.in);
int x = input.nextInt();
if(x%2==0)
System.out.println("Even");
else
System.out.println("Odd");
Programming language
Practical exam 2013 Code: Name:
The following table shows the employee code and the percentage of bonus for the
value of basic pay
Employee code Bonus
100 5
200 1
300 2
400 25
Write program using switch to find the bonus for the employee code?




Programming language
Practical exam 2013 Code: Name:
Write a java program to get the week day number (1-7) from the user and then print
the corresponding day name for example (if day =1 then print Saturday , using if-
else and switch case?


Scanner input = new Scanner(System.in);
int x = input.nextInt();
if(x==1)
System.out.println("Saturday");
else if(x==2)
System.out.println("Sunday");
else if(x==3)
System.out.println("Monday");
else if(x==4)
System.out.println("Tuesday");
else if(x==5)
System.out.println("Wednesday");
else if(x==6)
System.out.println("Saturday");
else if(x==7)
System.out.println("Friday");
else
System.out.println("Error");

Programming language
Practical exam 2013 Code: Name:

Write program that display even numbers from 2-44?



for(int i =2;i<=44;i+=2)
System.out.println(i);
Programming language
Practical exam 2013 Code: Name:
Write a Java application that uses looping to print the following table
of values:
N 10*N 100*N 1000*N
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000





Programming language
Practical exam 2013 Code: Name:

Write program that display odd numbers from 99-1?

Programming language
Practical exam 2013 Code: Name:

Write an application that displays the following patterns
separately one below the other.


Programming language
Practical exam 2013 Code: Name:
Write for loop that display numbers from 1-100?

Programming language
Practical exam 2013 Code: Name:
Write a program to get the month number from the user (1-12) print the name of
the month if input >12 then print thats not available month?


Programming language
Practical exam 2013 Code: Name:
Write program that get the input mark from the user through keyboard check the
following condition
mark output
<40 Fail
>50 Good
>75 Very good
>90 Excellent

Das könnte Ihnen auch gefallen