Answer to Question #207323 in C# for Jerald Advincula

Question #207323

A problem that computes the cost of postage on a first-class letter according to the following

rate: Php12.30 for the first ounce, Php 8.25 for each additional ounce, plus a Php 25.50 service

charge if the customer desires special delivery.


1
Expert's answer
2021-06-15T11:11:14-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace Q207323
{
    class Program
    {
        static void Main(string[] args)
        {
            float costPostage = 12.30f;
            float numberOunce = 0;
            float delivery=0.0f;
            // Php12.30 for the first ounce, Php 8.25 for each additional ounce
            Console.Write("Enter number of ounce: ");
            float.TryParse(Console.ReadLine(), out numberOunce);
            string answer = " ";
            while (answer.ToLower().CompareTo("n") != 0 && answer.ToLower().CompareTo("y") != 0)
            {
                Console.Write("Do you desire special delivery? (y/n): ");
                answer=Console.ReadLine();
            }
            // Php 25.50 service charge if the customer desires special delivery.
            if (answer.ToLower().CompareTo("y") == 0) {
                delivery = 25.50f;
                costPostage += delivery;
            }
            if (numberOunce > 1) {
                costPostage += (numberOunce - 1.0f) * 8.25f;
            }
            Console.WriteLine("\nSpecial delivery: {0}", delivery);
            Console.WriteLine("The cost of postage on a first-class letter: {0}", costPostage);
           


            Console.ReadLine();
        }


       
      


    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS