예제 #1
0
        }                                          // Calculates temperature based on user input for all the months

        static double getTemp(string month)
        {
            double temp;

            Console.Write("How hot was it in {0}: ", month);

            temp = StringParse.Double();

            return(temp);
        }                                  // Grabs a double and returns it
예제 #2
0
        }                         // More range practice

        static double getPackWeight()
        {
            double number;

            Console.Write("Enter the package weight: ");

            number = StringParse.Double();

            return(number);
        }                                        // Grabs a double of package weight
예제 #3
0
        }                                            // Calculates overtime pay based on hours and given payrate

        // Book Thing
        static void howManyBooks()
        {
            int    book_num;
            double book_price;
            double total_cost;
            double total_cost_discounted;
            double discount;

            Console.Write("How many books are you gonna need: ");
            book_num = StringParse.Int();

            Console.Write("How much does the book cost: ");
            book_price = StringParse.Double();

            discount              = discountDecider(book_num);
            total_cost            = book_num * book_price;
            total_cost_discounted = total_cost * discount;

            Console.WriteLine("You have received a discount of {0} off!", (discount).ToString("0%"));
            Console.WriteLine("Your total is {0}", (total_cost - discount).ToString("$0.00"));
            Console.WriteLine("Without the discount your total would have been {0}", (total_cost).ToString("$0.00"));
            Console.WriteLine("You saved {0} from your discount.", (total_cost_discounted).ToString("$0.00"));
        }                                           // Calculates a discount rate and discount amount based on number of books bought
예제 #4
0
        // Overtime compensation
        static void hoursWorked()
        {
            double hours;
            double overtime    = 0;
            double hourly_wage = 11.50;
            double overtime_payed;
            double regular_wage;
            double total_amount;

            Console.Write("How many hours have you worked this week: ");

            hours = StringParse.Double();

            if (hours < 40)
            {
                Console.WriteLine("No overtime this week.");
            }
            else
            {
                overtime = hours - 40;

                Console.WriteLine("You have {0} hours of overtime this week", overtime);
            }

            overtime_payed = (overtime * hourly_wage) * 1.5;
            regular_wage   = hours * hourly_wage;
            total_amount   = overtime_payed + regular_wage;

            Console.WriteLine(
                "Total overtime payed this week is {0} \n" +
                "Total non-overtime payed this week is {1} \n" +
                "Total amount earned this week is {2}"
                , overtime_payed
                , regular_wage
                , total_amount
                );
        }                                            // Calculates overtime pay based on hours and given payrate