Answer to Question #175324 in C++ for Bobby

Question #175324

Write a program in BASIC that compute total charges for phones sold and displays this information to the screen.


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.


1
Expert's answer
2021-03-25T03:29:30-0400
Module Module1


    Sub Main()
        Dim pricePhone As Double = 0
        Dim grandTotalNumberPhonesSold As Integer = 0
        Dim totalAllTotalCharges As Double = 0


        While pricePhone >= 0
            'prompt the user for the price of a phone. 
            Console.Write("Enter the price of a phone (-1 to close): ")
            pricePhone = Double.Parse(Console.ReadLine())
            If (pricePhone >= 0) Then
                'Compute the sales tax for this value
                Dim salesTax As Double = calculateSalesTax(pricePhone)
                Dim totalCharge As Double = calculateTotalCharge(pricePhone, salesTax)
                'Display the phone price, the dollar amount of the sales tax, and the total charge for this purchase. 
                Console.WriteLine("The phone price: " + pricePhone.ToString("C"))
                Console.WriteLine("The sales tax: " + salesTax.ToString("C"))
                Console.WriteLine("The total charge: " + totalCharge.ToString("C"))
                Console.WriteLine()
                grandTotalNumberPhonesSold += 1
                totalAllTotalCharges += totalCharge
            End If
        End While
       
        'After all the data has been entered, display a grand total of number of phones sold, and a grand total of all total charges.
        Console.WriteLine()
        Console.WriteLine("The grand total of number of phones sold: " + grandTotalNumberPhonesSold.ToString())
        Console.WriteLine("The grand total of all total charges: " + totalAllTotalCharges.ToString("C"))
        Console.ReadLine()
    End Sub


    ''' <summary>
    '''  Calculates sales tax is calculated as 7% of the price of the phone. 
    ''' </summary>
    ''' <param name="pricePhone"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function calculateSalesTax(ByVal pricePhone As Double) As Double
        Return pricePhone * 0.07D
    End Function
    ''' <summary>
    ''' Total charge is the price plus the sales tax amount.
    ''' </summary>
    ''' <param name="pricePhone"></param>
    ''' <param name="salesTax"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function calculateTotalCharge(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