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.
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();
}
}
}
Comments
Leave a comment