settingsAccountsettings
Menusettings

Q: Prospect in Hospitality - C# Task

+3 votes

Bai Shura from Blagoevgrad was once very good at chemistry and physics. Winning every single contest and being so ambitious, he decided to go abroad in a top university to develop his skills in something a bit different from what he had studied before. Surprisingly or not, he got accepted in the MIH (Massachusetts Institute of Hospitality) in the USA with full scholarship. Getting advantage from his previously acquired knowledge he managed to finish in the top 10 students at the university.

When Shura got back to Bulgaria, the world-famous investor Adem James saw a good opportunity in him.  Mr. James decided to invest a big amount of money in making Bai Shura a big hotel owner in Bulgaria. The only thing the young lad had to do was to introduce an exhaustive project plan with the amount of money and staff needed to the investor. You are one of Bai Shura’s close friends and the main programmer of the hotel and not surprisingly you’ll be awarded some big amount of money to do your task.

Bai Shura told you that he needs exactly ‘b’ builders, ‘r’ receptionists, ‘c’ chambermaids, ‘t’ technicians and ‘o’ others (managers, restaurant staff, security guards, piccolo, etc.). He also provided you with this table with the salary for each group in leva:

c# task - table

Bai Shura was very good so he knew exactly how many people were needed from every group. Suddenly, he remembered that he forgot that he needed a lawyer for all the preparations and in order to make everything legal. He thought of his old friend Niki, who finished Hawaii’s Law School amongst top students, and contacted him. Niki answered immediately and agreed on the salary of n USD (USA’s currency – US Dollars). You’ll be given the number of members for each group, the USA currency (not necessarily the real one), Niki’s salary in USD, the budget and your salary. Your task is to help your friend and write a program that calculates the amount of money needed for salaries of all hotel’s staff members including yours and excluding Shura’s who would be awarded by Mr. James separately depending on the hotel’s further development. You should also calculate whether the amount is less or equal to the budget ‘m’. And what’s the difference between budget ‘m’ and money needed.

Input

The input data should be read from the console. It consists of nine input values, each at a separate line:

  • The number b – amount of builders needed.
  • The number r – amount of receptionists needed.
  • The number c – amount of chambermaids needed.
  • The number t – amount of technicians needed.
  • The number o – amount of other staff members needed.
  • The number n – Niki’s salary in USD.
  • The number u – USA’s currency rate at the moment.
  • The number s – your salary.
  • The number m – the budget.

The input data will always be valid and in the format described. There is no need to check it explicitly.

Output

  • The output data must be printed on the console.
  • On the first output line you must print the exact amount of money needed for salaries in following format: “The amount is: {amount} lv.”
  • On the second output line print:
  • If budget is enough: “YES \ Left: {money left} lv.”
  • Else: “NO \ Need more: {needed money} lv.”
  • All amounts must be in leva and rounded to two decimal places.

Constraints

  • The numbers b, r, c, t and o are integers in the range [0 ... 4 294 967 285].
  • The numbers n, u, m and s are floating-point numbers in the range [0 … 7.9 x 1028].
  • Allowed working time for your program: 0.1 seconds.
  • Allowed memory: 16 MB.

Examples

example 1

example 2

 

asked in C# category by user nikole
edited by user golearnweb

1 Answer

+2 votes
 
Best answer

Interesting task :-) Here is my solution:

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

class ProspectInHospitality
{
    static void Main()
    {
        decimal builders = decimal.Parse(Console.ReadLine());//The amount of builders needed.
        decimal receptionists = decimal.Parse(Console.ReadLine());//The amount of receptionists needed.
        decimal chambermaids = decimal.Parse(Console.ReadLine());//The amount of chambermaids needed.
        decimal technicians = decimal.Parse(Console.ReadLine());//The amount of technicians needed.
        decimal others = decimal.Parse(Console.ReadLine());//The amount of other staff members needed.
        decimal nikiSalaryUS = decimal.Parse(Console.ReadLine());//Niki’s salary in USD.
        decimal usRateToBG = decimal.Parse(Console.ReadLine());//USA’s currency rate at the moment.
        decimal mySalary = decimal.Parse(Console.ReadLine());//Your salary.
        decimal budget = decimal.Parse(Console.ReadLine());//The overall budget.

        decimal allSalaries = 0;
        allSalaries += builders * 1500.04m;
        allSalaries += receptionists * 2102.10m;
        allSalaries += chambermaids * 1465.46m;
        allSalaries += technicians * 2053.33m;
        allSalaries += others * 3010.98m;
        allSalaries += nikiSalaryUS * usRateToBG;
        allSalaries += mySalary;

        if (budget >= allSalaries)
        {
            Console.WriteLine("The amount is: {0:f2} lv.", allSalaries);
            Console.WriteLine("YES \\ Left: {0:f2} lv.", budget - allSalaries);
        }
        else if (budget < allSalaries)
        {
            Console.WriteLine("The amount is: {0:f2} lv.", allSalaries);
            Console.WriteLine("NO \\ Need more: {0:f2} lv.", allSalaries - budget);
        }
    }
}
answered by user richard8502
selected by user nikole
Fast answer! thank you Richard! It works! :-)))
...