Gross Wage Assignment Homework: Solve for Bangladesh, China, DR & Haiti

  • Thread starter Thread starter Veronica_Oles
  • Start date Start date
  • Tags Tags
    Assignment
Click For Summary
SUMMARY

The forum discussion centers on a C# program designed to calculate gross wages based on hours worked and hourly rates, specifically addressing wage calculations for Bangladesh, China, the Dominican Republic, and Haiti. The issue raised involves incorrect outputs for the gross wages of these countries due to the use of uninitialized variables in method calls. The solution provided emphasizes passing the correct hours worked to the respective methods for accurate calculations.

PREREQUISITES
  • Understanding of C# programming language
  • Familiarity with basic programming concepts such as methods and variable initialization
  • Knowledge of conditional statements in programming
  • Basic understanding of wage calculation formulas
NEXT STEPS
  • Review C# method parameter passing techniques
  • Learn about variable scope and initialization in C#
  • Explore error handling in C# to manage user input
  • Study wage calculation algorithms for different countries
USEFUL FOR

Students learning C# programming, software developers working on payroll applications, and anyone interested in understanding wage calculations across different countries.

Veronica_Oles
Messages
141
Reaction score
3

Homework Statement


Have to write a program that outputs the users gross wage. If the hours are over 40 then the hourly rate gets multiplied by 1.5.

We also have to output the salary people would get from different countries:

Bangladesh 0.15 cents
China 0.48 cents
Dominican Republic 1.60 dollars
Haiti 0.55 cents

This is all on c#.

Homework Equations

The Attempt at a Solution


Mod note: Added code tags
C:
static void Main(string[] args)
  {

  double dblHrsWorked = 0;
  double dblHrlyRate = 0;
  double grossWageBan = 0;
  double grossWageChi = 0;

  Console.Write("Please enter the hours worked: ");
  dblHrsWorked = double.Parse(Console.ReadLine());

  Console.WriteLine("Please enter the hourly rate($): ");
  dblHrlyRate = double.Parse(Console.ReadLine());

  Console.WriteLine("You make a total of " + (GrossWage(dblHrsWorked, dblHrlyRate)) + " dollars.");

  Console.WriteLine("People in the following countries make this amount of money: Bangladesh: " + (GrossWageBangladesh(grossWageBan)) + " dollars, China: " + (GrossWageChina(grossWageChi)) +" dollars.");

  Console.ReadKey();
  }  static double GrossWage (double hours, double rate)
  {

  double dblGrossWage = 0;

  if (hours > 40)
  {
  dblGrossWage = 40 * rate;

  dblGrossWage = dblGrossWage + ((hours - 40) * (rate * 1.5));

  }

  else
  {

  dblGrossWage = hours * rate;
  }

  return dblGrossWage;  }

  static double GrossWageBangladesh (double hours)
  {

  double dblBanGrossWage = 0;

  dblBanGrossWage = hours * 0.15;

  return dblBanGrossWage;

  }

  static double GrossWageChina(double hours)
  {

  double dblChinaGrossWage = 0;

  dblChinaGrossWage = hours * 0.48;

  return dblChinaGrossWage;

  }
  }
  }

I can't seem to figure out why the countries are not working can someone please Help me figure it out!
 
Physics news on Phys.org
Veronica_Oles said:

Homework Statement


Have to write a program that outputs the users gross wage. If the hours are over 40 then the hourly rate gets multiplied by 1.5.

We also have to output the salary people would get from different countries:

Bangladesh 0.15 cents
China 0.48 cents
Dominican Republic 1.60 dollars
Haiti 0.55 cents

This is all on c#.

Homework Equations

The Attempt at a Solution


Mod note: Added code tags
C:
static void Main(string[] args)
  {

  double dblHrsWorked = 0;
  double dblHrlyRate = 0;
  double grossWageBan = 0;
  double grossWageChi = 0;

  Console.Write("Please enter the hours worked: ");
  dblHrsWorked = double.Parse(Console.ReadLine());

  Console.WriteLine("Please enter the hourly rate($): ");
  dblHrlyRate = double.Parse(Console.ReadLine());

  Console.WriteLine("You make a total of " + (GrossWage(dblHrsWorked, dblHrlyRate)) + " dollars.");

  Console.WriteLine("People in the following countries make this amount of money: Bangladesh: " + (GrossWageBangladesh(grossWageBan)) + " dollars, China: " + (GrossWageChina(grossWageChi)) +" dollars.");

  Console.ReadKey();
  }  static double GrossWage (double hours, double rate)
  {

  double dblGrossWage = 0;

  if (hours > 40)
  {
  dblGrossWage = 40 * rate;

  dblGrossWage = dblGrossWage + ((hours - 40) * (rate * 1.5));

  }

  else
  {

  dblGrossWage = hours * rate;
  }

  return dblGrossWage;  }

  static double GrossWageBangladesh (double hours)
  {

  double dblBanGrossWage = 0;

  dblBanGrossWage = hours * 0.15;

  return dblBanGrossWage;

  }

  static double GrossWageChina(double hours)
  {

  double dblChinaGrossWage = 0;

  dblChinaGrossWage = hours * 0.48;

  return dblChinaGrossWage;

  }
  }
  }

I can't seem to figure out why the countries are not working can someone please Help me figure it out!
When you call your GrossWageBan() and GrossWageChi() methods, you are passing a value of 0 for hours to each method. You should be passing the number of hours in the calls to these methods, not grossWageBan and grossWageChi. These two variables are initialized to zero.