1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Molodets [167]
3 years ago
13

Develop a C# console application that will determine the gross pay for each of three employees. The company pays straight time f

or the first 40 hours worked by each employee and time and a half for all hours worked in excess of 40 hours. You are given a list of the three employees of the company, the number of hours each employee worked last week, and the hourly rate of each employee. Your application should input this information for each employee and should determine and display the employee’s gross pay. Use the Console class’s ReadLine method to input the data. Use a while loop to implement the inputs and calculations.
Computers and Technology
1 answer:
I am Lyosha [343]3 years ago
3 0

Answer:

The c# program for the scenario is shown.

using System;

class main {

 static void Main() {

   

// arrays to hold details of employees are declared

// double datatype is taken to accommodate all types of numerical values  

     int[] empid = new int[3];

     double[] hours = new double[3];

     double[] pay = new double[3];

     double[] pay_overtime = new double[3];

     double hrs = 40.00;

     double[] total_pay = new double[3];

     

   Console.WriteLine("Enter the details for the three employees ");

// variable declared and initialized for the loop    

   int i=0;

   while(i<3)

   {

       Console.WriteLine("Enter the id");

       empid[i] = Convert.ToInt32(Console.ReadLine());  

       

       Console.WriteLine("Enter the working hours");

       hours[i] = Double.Parse(Console.ReadLine());

       

       Console.WriteLine("Enter the hourly pay");

       pay[i] = Double.Parse(Console.ReadLine());

       pay_overtime[i] = pay[i]*1.5;

       

       i++;

       

   }

   

   Console.WriteLine("The details for the three employees ");

   // variable set to 0 to be re-used in the loop

   i=0;

   

   while(i<3)

   {

       if(hours[i] > hrs)

           total_pay[i] = ( hrs*pay[i] );

       else

           total_pay[i] = ( hours[i]*pay[i] );

       

       if(hours[i] > hrs)

           total_pay[i] = total_pay[i] + ( (hours[i]-hrs)*pay_overtime[i] );

       

       i++;

       

   }

// variable set to 0 to be re-used in the loop

   i=0;

   

   while(i<3)

   {

       Console.WriteLine("Gross pay of employee " + (i+1) + " : " + total_pay[i] );

   

       i++;

   }

   

   

 }

}  

OUTPUT

Enter the details for the three employees  

Enter the id

1

Enter the working hours

35

Enter the hourly pay

10

Enter the id

2

Enter the working hours

40

Enter the hourly pay

10

Enter the id

3

Enter the working hours

45

Enter the hourly pay

10

The details for the three employees  

Gross pay of employee 1 : 350

Gross pay of employee 2 : 400

Gross pay of employee 3 : 475  

Explanation:

The program works as described.

1. Arrays to hold each piece of information for the employee, employee number, hourly pay, overtime pay and hours worked, are declared.

2. User input is taken inside while loop to fill each array for each employee.

3. The total gross pay for each employee is calculated inside another while loop.

4. The last while loop is used to display the gross pay for each employee.

You might be interested in
An email message containing a warning related to a non-existent computer security threat, asking a user to delete system files f
LenKa [72]

Answer: Virus Hoax

Explanation:

A computer virus hoax is a message that warns someone of a false virus threat. It is a a chain email that encourages who ever has received the message to pass it to other people as a form of warning.

5 0
2 years ago
How can I link two classes together with spigot to make it so I can open a method within the said class. Trying to open my class
Andreyy89

Answer:

add the following code to your bar class

Explanation:

public Bar(Commands n) { }

5 0
2 years ago
Implement a Java program that creates math flashcards for elementary grade students. User will enter his/her name, the type (+,
jeka57 [31]

import java.util.Scanner;

public class JavaApplication44 {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.print("Enter you name: ");

       String name = scan.nextLine();

       System.out.print("Enter your operation (+,-,*,/): ");

       String operator = scan.nextLine();

       System.out.print("Enter the range of the problems: ");

       int ran = scan.nextInt();

       System.out.print("Enter number of problems: ");

       int problems = scan.nextInt();

       int score = 0;

       for (int i = 1; i <= ran; i++){

           int first = (int)(Math.random()*ran);

           int sec = (int)(Math.random()*ran);

           System.out.print("Problem #"+i+": "+first + " "+operator+" "+sec+" = ");

           int ans = scan.nextInt();

           if (operator.equals("+")){

               if (ans == first + sec){

                   System.out.println("Correct!");

                   score++;

               }

               else{

                   System.out.println("Wrong. The correct answer is "+(first+sec));

               }

           }

           else if(operator.equals("-")){

               if (ans == first - sec){

                   System.out.println("Correct");

                   score++;

               }

               else{

                   System.out.println("Wrong. The correct answer is "+(first - sec));

               }

           }

           else if (operator.equals("*")){

               if (ans == first * sec){

                   System.out.println("Correct");

                   score++;

               }

               else{

                   System.out.println("Wrong. The correct answer is "+(first * sec));

               }

           }

           else if (operator.equals("/")){

               if (ans == first / sec){

                   System.out.println("Correct");

                   score++;

               }

               else{

                   System.out.println("Wrong. The correct answer is "+(first / sec));

               }

           }

           

       }

       System.out.println(name+", you answered "+score+" questions correctly.");

   }

   

}

I hope this helps!

8 0
3 years ago
Let's implement a classic algorithm: binary search on an array. Implement a class named BinarySearcher that provides one static
yKpoI14uk [10]

Answer:

Hope this helped you, and if it did , do consider giving brainliest.

Explanation:

import java.util.ArrayList;

import java.util.List;

//classs named BinarySearcher

public class BinarySearcher {

 

//   main method

  public static void main(String[] args) {

     

//   create a list of Comparable type

     

      List<Comparable> list = new ArrayList<>();

     

//       add elements

     

      list.add(1);

      list.add(2);

      list.add(3);

      list.add(4);

      list.add(5);

      list.add(6);

      list.add(7);

     

//       print list

     

      System.out.println("\nList : "+list);

     

//       test search method

     

      Comparable a = 7;

      System.out.println("\nSearch for 7 : "+search(list,a));

     

      Comparable b = 3;

      System.out.println("\nSearch for 3 : "+search(list,b));

     

      Comparable c = 9;

      System.out.println("\nSearch for 9 : "+search(list,c));

     

      Comparable d = 1;

      System.out.println("\nSearch for 1 : "+search(list,d));

     

      Comparable e = 12;

      System.out.println("\nSearch for 12 : "+search(list,e));

     

      Comparable f = 0;

      System.out.println("\nSearch for 0 : "+search(list,f));

     

  }

 

 

 

//   static method named search takes arguments Comparable list and Comparable parameter

  public static boolean search(List<Comparable> list, Comparable par) {

     

//       if list is empty or parameter is null the throw IllegalArgumentException

     

      if(list.isEmpty() || par == null ) {

         

          throw new IllegalArgumentException();

         

      }

     

//       binary search

     

//       declare variables

     

      int start=0;

     

      int end =list.size()-1;

     

//       using while loop

     

      while(start<=end) {

         

//           mid element

         

          int mid =(start+end)/2;

         

//           if par equal to mid element then return

         

          if(list.get(mid).equals(par) )

          {

              return true ;

             

          }  

         

//           if mid is less than parameter

         

          else if (list.get(mid).compareTo(par) < 0 ) {

                 

              start=mid+1;

          }

         

//           if mid is greater than parameter

         

          else {

              end=mid-1;

          }

      }

     

//       if not found then retuen false

     

      return false;

     

  }

 

 

}import java.util.ArrayList;

import java.util.List;

//classs named BinarySearcher

public class BinarySearcher {

 

//   main method

  public static void main(String[] args) {

     

//   create a list of Comparable type

     

      List<Comparable> list = new ArrayList<>();

     

//       add elements

     

      list.add(1);

      list.add(2);

      list.add(3);

      list.add(4);

      list.add(5);

      list.add(6);

      list.add(7);

     

//       print list

     

      System.out.println("\nList : "+list);

     

//       test search method

     

      Comparable a = 7;

      System.out.println("\nSearch for 7 : "+search(list,a));

     

      Comparable b = 3;

      System.out.println("\nSearch for 3 : "+search(list,b));

     

      Comparable c = 9;

      System.out.println("\nSearch for 9 : "+search(list,c));

     

      Comparable d = 1;

      System.out.println("\nSearch for 1 : "+search(list,d));

     

      Comparable e = 12;

      System.out.println("\nSearch for 12 : "+search(list,e));

     

      Comparable f = 0;

      System.out.println("\nSearch for 0 : "+search(list,f));

     

  }

 

 

 

//   static method named search takes arguments Comparable list and Comparable parameter

  public static boolean search(List<Comparable> list, Comparable par) {

     

//       if list is empty or parameter is null the throw IllegalArgumentException

     

      if(list.isEmpty() || par == null ) {

         

          throw new IllegalArgumentException();

         

      }

     

//       binary search

     

//       declare variables

     

      int start=0;

     

      int end =list.size()-1;

     

//       using while loop

     

      while(start<=end) {

         

//           mid element

         

          int mid =(start+end)/2;

         

//           if par equal to mid element then return

         

          if(list.get(mid).equals(par) )

          {

              return true ;

             

          }  

         

//           if mid is less than parameter

         

          else if (list.get(mid).compareTo(par) < 0 ) {

                 

              start=mid+1;

          }

         

//           if mid is greater than parameter

         

          else {

              end=mid-1;

          }

      }

     

//       if not found then retuen false

     

      return false;

     

  }

 

 

}

7 0
2 years ago
Create a visual python quiz that pops up when you run the code
Irina-Kira [14]

Refer to the attachment!!

8 0
2 years ago
Other questions:
  • According to your textbook, which of the following is a consequence of the quick development of new technologies in the digital
    8·1 answer
  • What file may contain data written to it in case of an unexpected error or program shut-down?
    5·1 answer
  • In one sentences describe how to change your home page
    10·1 answer
  • A Windows application which demands a lot of raw processing power to execute repetitive complex calculations is a good candidate
    5·1 answer
  • The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
    14·1 answer
  • PLEASE HELP!!!!!!!!!!! The Excel tool that extends the height of a selected cell so that all the text fits into the cell and is
    10·2 answers
  • Using hard disk to temporarily store data or instructions from ram is referred to as the
    12·1 answer
  • Of the following field which would be the most appropriate for the primary key in a customer information table?
    5·1 answer
  • There u go i did thereeeeeeeeeeeeeeeeeeeeeee
    13·2 answers
  • The optical phenomenon that allows us to view rapidly changing still images as moving images is called _______.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!