0% found this document useful (0 votes)
36 views

Assignment

The document contains 5 programming problems: 1) A program to calculate overtime pay for 10 employees where overtime is paid at a rate of Rs. 12 per hour for hours worked over 40. 2) A program to calculate the factorial of a given number. 3) A program to calculate one number raised to the power of another number. 4) A program to print all ASCII values and their equivalent characters using a while loop. 5) A program to count the number of positive, negative and zero numbers entered by the user until they choose to quit.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Assignment

The document contains 5 programming problems: 1) A program to calculate overtime pay for 10 employees where overtime is paid at a rate of Rs. 12 per hour for hours worked over 40. 2) A program to calculate the factorial of a given number. 3) A program to calculate one number raised to the power of another number. 4) A program to print all ASCII values and their equivalent characters using a while loop. 5) A program to count the number of positive, negative and zero numbers entered by the user until they choose to quit.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.Write a program to calculate overtime pay of 10 employees.

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");
}
}
}
}

2. Write a program to find the factorial value of any number entered


through the keyboard.

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 {

public static void main(String[] args) {

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;

public class Pro35 {


public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int number,
countPositive = 0,
countNegative = 0,
countZero = 0;

char choice;

do
{
System.out.print("Enter the number ");
number = console.nextInt();

if(number > 0)
{
countPositive++;
}
else if(number < 0)
{
countNegative++;
}
else
{
countZero++;
}

System.out.print("Do you want to continue y/n? ");


choice = console.next().charAt(0);

}while(choice=='y' || choice == 'Y');


System.out.println("Positive numbers: " + countPositive);
System.out.println("Negative numbers: " + countNegative);
System.out.println("Zero numbers: " + countZero);

You might also like