Assignment
Assignment
Overtime
is paid at the rate of Rs. 12.00 per hour for every hour worked above 40
hours. Assume that employees do not work for fractional part of an
hour.
package pro3.pkg1;
import java.util.Scanner;
public class Pro31 {
public static void main(String[] args) {
for(int i=1;i<=10;i++)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the working hours of 10 Employee: ");
int workinghour =sc.nextInt();
if (workinghour>40)
{
int overtime=workinghour-40;
int payment=overtime*12;
System.out.println("your Overtime payment:"+payment);
}
else
{
System.out.println("You should have to work more than 40 hours for the
OT");
}
}
}
}
package pro3.pkg2;
import java.util.Scanner;
public class Pro32 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter the number for factorization");
int num=sc.nextInt();
int factorial=1;
int fact=1;
for(int i=1;i<=num;i++)
{
fact=(factorial* i);
}
System.out.println("Factorial of that number is:"+fact);
3. Write a program to find the value of one number raised to the power of
another.
package pro3.pkg3;
import java.util.Scanner;
import java.lang.Math;
public class Pro33 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
int a=sc.nextInt();
System.out.println("Enter the power to another number");
int p=sc.nextInt();
double num=Math.pow((double)a, (double)p);
System.out.println("power of the number:"+num);
}
4. Write a program to print all the ASCII values and their equivalent
characters using a while loop.
package pro3.pkg4;
public class Pro34 {
int i=0;
while(i<=255)
{
System.out.println("The ASCII values of character :"+i);
i=i+1;
}
}
5. Write a program to enter the numbers till the user wants and at the
end it should display the count of positive, negative and zeros entered.
package pro35;
import java.util.Scanner;
char choice;
do
{
System.out.print("Enter the number ");
number = console.nextInt();
if(number > 0)
{
countPositive++;
}
else if(number < 0)
{
countNegative++;
}
else
{
countZero++;
}