1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with psuedocode, please??

Discussion in 'Programming' started by holiks, Oct 6, 2011.

  1. holiks

    holiks New Member

    Oct 6, 2011
    Likes Received:
    Trophy Points:
    hello everyone, I wrote the following code but I have a hard time with psuedocode opposed to actual programming code so I'm not sure I correctky wrote this in psuedocode or not. Can someone please help me and let me know if this is actually correct psuedocode

    //Initialize Variables 
    Initialize LeadedPrice = user-defined value;
    Initialize UnleadedPrice = user-defined value;
    Initialize FedGasTaxLeadedRate = user-defined value;
    Initialize FedGasTaxUnleadedRate = user-defined value;
    Initialize GasnGoCharge = user-defined value;
    Initialize FullServiceCharge = user-defined value;
    Initialize StateSalesTax_Rate = user-defined value;
    Initialize Gallons;
    Initialize StateSalesTax;
    Initialize FedGasTax;
    Initialize GasChoice;
    Initialize GasCost;
    Initialize ServiceType;
    Initialize ExtraCharge;
    Initialize TotalCost;
    //Enables user to input the type of gas they prefer.
    Display "What type of gas would you like? Leaded or Unleaded. ";
    Input GasChoice;
    //Enables user to input the amount of gas wanted
    Display "How many gallons would you like? ";
    Input Gallons;
    //Enables user to input the type of service they want
    Display "Would you like: Gas-n-Go  or Full-Service? None. ";
    Input ServiceType;
    //Calculations of gas cost and federal gas tax for leaded
    If (GasChoice == "Leaded")
                GasCost = Gallons * LeadedPrice;
                FedGasTax = Gallons * FedGasTaxLeadedRate;
    //Calculations of gas cost and federal gas tax for unleaded
    Else if (GasChoice = "Unleaded")
                GasCost = Gallons * UnleadedPrice;
                FedGasTax = Gallons * FedGasTaxUnleadedRate;
    //Cost of extra charge for Gas n’ Go
    If (ServiceType == "Gas-n-Go")
                ExtraCharge = GasnGoCharge;
    //Cost of extra charge for Full Service
    Else if (ServiceType == "Full-Service")
                ExtraCharge = FullServiceCharge;
    //No extra charge if no extra service is wanted 
    Else if (ServiceType == "None")
                ExtraCharge = 0;
    //Calculation for State Sales Tax
    StateSalesTax = StateSalesTaxRate * (GasCost + ExtraCharge);
    //Calculation for the Total Cost to be charged to the customer
    TotalCost = GasCost + ExtraCharge + StateSales_Tax + FedGasTax;
    //Displays the breakdown of the bill
    Display "Total Gas Cost: ";
    Display GasCost;
    Display "Service Charge: ";
    Display ExtraCharge;
    Display "Federal Gas Tax: ";
    Display FedGasTax;
    Display "State Sales Tax: ";
    Display StateSalesTax;
    Display "Total Amount: ";
    Display TotalCost;
    Last edited by a moderator: Oct 7, 2011

Share This Page