Answer to Question #175929 in C++ for Bobby

Question #175929



The program must prompt the user for the price of a phone. Compute the sales tax for this value, and then display the phone price, the dollar amount of the sales tax, and the total charge for this purchase. Sales tax is calculated as 7% of the price of the phone. Total charge is the price plus the sales tax amount.

After all the data has been entered, display a grand total of number of phones sold, and a grand total of all total charges.

This program must use at least two subroutines.


*Program must be typed in BASIC




1
Expert's answer
2021-03-26T16:20:47-0400
Module Module1


    Sub Main()
        Dim pricePhone As Double = 0
        Dim totalPhonesSold As Integer = 0
        Dim totalCharges As Double = 0
        While pricePhone >= 0
            pricePhone = getPrice()
            If (pricePhone >= 0) Then
                Dim salesTax As Double = getSalesTax(pricePhone)
                Dim totalCharge As Double = getTotalCharge(pricePhone, salesTax)
                Console.WriteLine("The phone price: {0}", pricePhone.ToString("C"))
                Console.WriteLine("The sales tax: {0}", salesTax.ToString("C"))
                Console.WriteLine("The total charge: {0}", totalCharge.ToString("C"))
                Console.WriteLine()
                totalPhonesSold += 1
                totalCharges += totalCharge
            End If
        End While


        Console.WriteLine()
        Console.WriteLine("The grand number of phones sold: {0}", totalPhonesSold.ToString())
        Console.WriteLine("The grand charge: {0}", totalCharges.ToString("C"))
        Console.ReadLine()
    End Sub


    Function getPrice() As Double
        Console.Write("Enter the price of the phone (to end loop - enter a negative number): ")
        Dim pricePhone As Double = Double.Parse(Console.ReadLine())
        Return pricePhone
    End Function


    Function getSalesTax(ByVal pricePhone As Double) As Double
        Return pricePhone * 0.07D
    End Function


    Function getTotalCharge(ByVal pricePhone As Double, ByVal salesTax As Double) As Double
        Return pricePhone + salesTax
    End Function
End Module

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
New on Blog
APPROVED BY CLIENTS