Question

In: Computer Science

Can someone take a look and tell me what I have wrong here. VS 2019 .net...

Can someone take a look and tell me what I have wrong here. VS 2019 .net framework console app c##

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace dropbox10
{
class MainClass
{

public static void Main(string[] args)
{

//create a list of employees

List<Employee> allEmployees = new List<Employee>();

//create two full time employees

FullTimeEmployee fe1 = new FullTimeEmployee("111", "Alice", 67888.00m);
FullTimeEmployee fe2 = new FullTimeEmployee("222", "Bob", 67555.00m);
//create two part time employees
PartTimeEmployee pe1 = new PartTimeEmployee("333", "Chuck", 22.12m, 20m);
PartTimeEmployee pe2 = new PartTimeEmployee("444", "Dan", 23.33m, 18.45m);
//add employees to list
allEmployees.Add(fe1);
allEmployees.Add(fe2);
allEmployees.Add(pe1);
allEmployees.Add(pe2);
//display data

foreach (Employee emp in allEmployees)
{

Console.WriteLine(emp);

}
Console.ReadKey();
}
}

}
//the required employee class

class Employee
{
//fields
private string employeeId;

private string employeeName;
//properties
public string EmployeeId
{
get { return employeeId; }
set { employeeId = value; }
}
public string EmployeeName
{
get { return employeeName; }
set { employeeName = value; }
}
public Employee(string employeeId, string employeeName)
{

this.employeeId = employeeId;

this.employeeName = employeeName;

}

//required toString method

public override string ToString()

{

string str;
str = string.Format("ID: {0} Name: {1}", EmployeeId, EmployeeName);
return str;

}

}

//the required class

class FullTimeEmployee : Employee
{
//field
private decimal annualSalary;
//property
public decimal AnnualSalary
{
get { return annualSalary; }
set { annualSalary = value; }
}
//consturtor
public FullTimeEmployee(string employeeId, string employeeName, decimal annualSalary)
: base(employeeId, employeeName)
{

this.annualSalary = annualSalary;

}
//GetweeklyPaid() method
public decimal GetWeeklyPaid()
{
decimal payAmount;
payAmount = AnnualSalary / 52;
return payAmount;
}
//ToString() method
public override string ToString()

{
string str;
str = base.ToString() + string.Format(" Pay amount: {0:C}", GetWeeklyPaid());
return str;
}


class PartTimeEmployee : Employee
{
//fields
private decimal hourlyWage;
private decimal hoursWorked;
//properties
public decimal HourlyWage
{
get { return hourlyWage; }
set { hourlyWage = value; }
}
public decimal HoursWorked
{
get { return hoursWorked; }
set { hoursWorked = value; }
}
//constuctor

public PartTimeEmployee(string employeeId, string employeeName,
decimal hourlyWage, decimal hoursWorke)
: base(employeeId, employeeName)
{


this.hourlyWage = hourlyWage;
this.hoursWorked = hoursWorked;
}


//GetWeeklyPaid() method
public decimal GetWeeklyPaid()
{
decimal payAmount;
payAmount = HoursWorked * HourlyWage;
return payAmount;
}
//ToString() method
public override string ToString()

{
string str;
str = base.ToString() + string.Format(" Pay amount: {0:C}", GetWeeklyPaid());
return str;
}
}
}

Solutions

Expert Solution

Your have done mistake here

//constuctor

public PartTimeEmployee(string employeeId, string employeeName,
decimal hourlyWage, decimal hoursWorke)
: base(employeeId, employeeName)
{


this.hourlyWage = hourlyWage;
this.hoursWorked = hoursWorked;
}

hoursWorke here you have done typo error ists hoursWorked

----------------------------------------------------------------------------------------------------------

Updated code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dropbox10
{
class MainClass
{
static void Main(string[] args)
{
//create a list of employees
List<Employee> allEmployees = new List<Employee>();

//create two full time employees
FullTimeEmployee fe1 = new FullTimeEmployee("111", "Alice", 67888.00m);
FullTimeEmployee fe2 = new FullTimeEmployee("222", "Bob", 67555.00m);
//create two part time employees
PartTimeEmployee pe1 = new PartTimeEmployee("333", "Chuck", 22.12m, 20m);
PartTimeEmployee pe2 = new PartTimeEmployee("444", "Dan", 23.33m, 18.45m);
//add employees to list
allEmployees.Add(fe1);
allEmployees.Add(fe2);
allEmployees.Add(pe1);
allEmployees.Add(pe2);
//display data
foreach (Employee emp in allEmployees)
{
Console.WriteLine(emp);
}
Console.ReadKey();
}
}
//the required employee class
class Employee
{
//fields
private string employeeId;
private string employeeName;
//properties
public string EmployeeId
{
get { return employeeId; }
set { employeeId = value; }
}
public string EmployeeName
{
get { return employeeName; }
set { employeeName = value; }
}
public Employee(string employeeId, string employeeName)
{
this.employeeId = employeeId;
this.employeeName = employeeName;
}

//required toString method
public override string ToString()
{
string str;
str = string.Format("ID: {0} Name: {1}", EmployeeId, EmployeeName);
return str;
}
}
class FullTimeEmployee : Employee
{
//field
private decimal annualSalary;
//property
public decimal AnnualSalary
{
get { return annualSalary; }
set { annualSalary = value; }
}
//consturtor
public FullTimeEmployee(string employeeId, string employeeName, decimal annualSalary)
: base(employeeId, employeeName)
{
this.annualSalary = annualSalary;
}
//GetweeklyPaid() method
public decimal GetWeeklyPaid()
{
decimal payAmount;
payAmount = AnnualSalary / 52;
return payAmount;
}
//ToString() method
public override string ToString()
{
string str;
str = base.ToString() + string.Format(" Pay amount: {0:C}", GetWeeklyPaid());
return str;
}
}
class PartTimeEmployee : Employee
{
//fields
private decimal hourlyWage;
private decimal hoursWorked;
//properties
public decimal HourlyWage
{
get { return hourlyWage; }
set { hourlyWage = value; }
}
public decimal HoursWorked
{
get { return hoursWorked; }
set { hoursWorked = value; }
}
//constuctor
public PartTimeEmployee(string employeeId, string employeeName,
decimal hourlyWage, decimal hoursWorked)
: base(employeeId, employeeName)
{
this.hourlyWage = hourlyWage;
this.hoursWorked = hoursWorked;
}
//GetWeeklyPaid() method
public decimal GetWeeklyPaid()
{
decimal payAmount;
payAmount = HoursWorked * HourlyWage;
return payAmount;
}
//ToString() method
public override string ToString()
{
string str;
str = base.ToString() + string.Format(" Pay amount: {0:C}", GetWeeklyPaid());
return str;
}
}
}
output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

can someone tell me if i am wrong on any of these???? THANKS In order to...
can someone tell me if i am wrong on any of these???? THANKS In order to be able to deliver an effective persuasive speech, you need to be able to detect fallacies in your own as well as others’ speeches. The following statements of reasoning are all examples of the following fallacies: Hasty generalization, mistaken cause, invalid analogy, red herring, Ad hominem, false dilemma, bandwagon or slippery slope. 1. __________bandwagon fallacy_______ I don’t see any reason to wear a helmet...
Okay, can someone please tell me what I am doing wrong?? I will show the code...
Okay, can someone please tell me what I am doing wrong?? I will show the code I submitted for the assignment. However, according to my instructor I did it incorrectly but I am not understanding why. I will show the instructor's comment after providing my original code for the assignment. Thank you in advance. * * * * * HourlyTest Class * * * * * import java.util.Scanner; public class HourlyTest {    public static void main(String[] args)     {        ...
I have to complete a template for pathophysiology , can someone tell me the pathophysiology of...
I have to complete a template for pathophysiology , can someone tell me the pathophysiology of pain. This is for a pathophysiology class
Can someone tell me what is wrong with this code? Python pong game using graphics.py When...
Can someone tell me what is wrong with this code? Python pong game using graphics.py When the ball moves the paddles don't move and when the paddles move the ball doesn't move. from graphics import * import time, random def racket1_up(racket1):    racket1.move(0,20)        def racket1_down(racket1):    racket1.move(0,-20)   def racket2_up(racket2):    racket2.move(0,20)   def racket2_down(racket2):    racket2.move(0,-20)   def bounceInBox(shape, dx, dy, xLow, xHigh, yLow, yHigh):     delay = .005     for i in range(600):         shape.move(dx, dy)         center = shape.getCenter()         x = center.getX()         y = center.getY()         if x...
Can someone please tell me on how can I have a double and character as one...
Can someone please tell me on how can I have a double and character as one of the items on my list? Thanks! This is what I got so far and the values I am getting are all integers. #pragma once #include <iostream> class Node { public:    int data;    Node* next;       // self-referential    Node()    {        data = 0;        next = nullptr;    }    Node(int value)    {        data...
Could someone please tell me what corrections I should make to this code. (Python) Here are...
Could someone please tell me what corrections I should make to this code. (Python) Here are the instructions. Modify the program so it contains four columns: name, year, price and rating (G,PG,R…) Enhance the program so it provides a find by rating function that lists all of the movies that have a specified rating I can't get the find function to work and I have no idea how to even go about it. For example, when type in 'find' and...
Can someone look into my code and tell me what do you think: Thats Palindrome; //class...
Can someone look into my code and tell me what do you think: Thats Palindrome; //class name Palindrome public class Palindrome {    public static void palindromeChecker(String... str) {        // takes string one by one        for (String s : str) {            // creates a stringbuilder for s            StringBuilder sb = new StringBuilder(s);            // reverses the sb            sb.reverse();            // checks if both...
Can someone show me how this is supposed to look in a table format. I want...
Can someone show me how this is supposed to look in a table format. I want to double check that I'm formatting and doing the numbers properly. Thank you! Timber Construction constructs furniture.  They’ve decided they need to layout out their budgets for the first Quarter of 2019 to see if they will make a profit and have cash for a future expansion that will cost $400,000. They always must keep $100,000 minimum in the checking account every month.  (Assume the beginning...
Can someone tell me how to fix warning msg in my code of C ++? I...
Can someone tell me how to fix warning msg in my code of C ++? I got run-time error for this question please help me asap! Errors are: In function 'void bfs(int, int)': warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < adj[pppp].size(); j++){ ^ In function 'int main()': warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d %d %d %d", &a, &q, &c, &N, &m); ^...
Can someone please tell me why I am getting errors. I declared the map and it's...
Can someone please tell me why I am getting errors. I declared the map and it's values like instructed but it's telling me I'm wrong. #include <iostream> #include <stdio.h> #include <time.h> #include <chrono> #include <string> #include <cctype> #include <set> #include <map> #include "d_state.h" using namespace std; int main() { string name; map<string,string> s; map<string,string>::iterator it; s[“Maryland”] = "Salisbury"; s[“Arizona”] = "Phoenix"; s[“Florida”] = "Orlando"; s[“Califonia”] = "Sacramento"; s[“Virginia”] = "Richmond"; cout << "Enter a state:" << endl; cin >> name;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT