Welcome to Gaia! ::


Aged Gaian

Edit: I need help on this my code is not working.

{
class Program
{
static void Main(string[] args)
{
int GP, BS, HR, HRR, RS, PR, Alwnce, OW;

Console.WriteLine("Input HOURS of work: " ) ;
HR = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input HOURLY RATE: " ) ;
HRR = Convert.ToInt32(Console.ReadLine() ) ;
Console.WriteLine("Input Living Allowance: " ) ;
Alwnce = Convert.ToInt32(Console.ReadLine() ) ;

if (HR > 160)
{
PR = HR * HRR;
OW = HR - 160;
GP = RS + Alwnce;
RS = HR * HRR;


Console.WriteLine("Premium rate is: " + PR) ;
Console.WriteLine("Overtime Work is: " + OW) ;
Console.WriteLine("Gross Pay: " + GP) ;

}
else
{

Console.WriteLine("Regular Rate: " + RS) ;
}
Console.ReadKey() ;
}
}
}


Meaning:

GP = Grosspay
BS = Basic salary
HR = Hours
HRR = Hourlyrate
RS = Regular Salary
BS = Bonus Salary
Alwnce = Allowance
OW = Overtimework
Are you sure hours and hourly rate should be integers?
I think half of your question is missing, because "Meanwhile, Grosspay is equal o the sum of an employee." doesn't make a whole lot sense.

Anyways, do the math in your head first. What do you want to get and how can you achieve this with the information you have? Try to express it as mathematical formula, if it helps you write it down on paper first. If you know what numbers you need and what should happen with them write the program.
You can either assign an integer to RS for example: int RS=100; or take RS = HR * HRR; out from the if statement like this.

RS = HR * HRR;
if (HR > 160)
{

PR = HR * HRR;
OW = HR - 160;
GP = RS + Alwnce;

I think it's fine for your to put hours as integer, maybe you should choose double or float as the data type for Grosspay, Regular Salary, Hourlyrate, Regular Salary, Allowance and Bonus Salary.

8,950 Points
  • Gaian 50
  • Member 100
  • Contributor 150
First of all, please use a pastebin service such as pastebin.com or gist.github.com to share your code. Gaia is known to have a broken parser which makes it difficult to share code on the site.

Rubytic
Meaning:

GP = Grosspay
BS = Basic salary
HR = Hours
HRR = Hourlyrate
RS = Regular Salary
BS = Bonus Salary
Alwnce = Allowance
OW = Overtimework


Protip: Don't use a glossary for your variable names. Just use longer names that are unambiguous. I would not hire you as a developer (or reject your patches to one of my projects) for using those abbreviated variable names.

The Committee Staff Gaian

9,775 Points
  • Elysium's Gatekeeper 100
  • Noble Shade 100
  • Battle: Cleric 100
Can you be more descriptive? What exactly isn't functioning, what did you want it to do and what is it doing instead?

Quick Reply

Submit
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum