Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Intro to C++ Program I need help on my programming assignment I can\'t seem to g

ID: 3757711 • Letter: I

Question

Intro to C++ Program

I need help on my programming assignment I can't seem to get the right results at the end. The question is:

An Internet service provider has three different subscription packages for its customers:

Package A: For $15 per month with 50 hours of access provided.

               Additional hours are $2.00 per hour over 50 hours.

               Assume usage is recorded in one-hour increments,

Package B: For $20 per month with 100 hours of access provided.

               Additional hours are $1.50 per hour over 100 hours.   

   Package C: For $25 per month with 150 hours access is provided.

                   Additional hours are $1.00 per hour over 150 hours

           

      Write a program that calculates a customer’s monthly charges.

      Implement with the following functions for your solution.

         getPackage

         validPackage

         getHours

         validHours

         calculatePkg_A

         calculatePkg_B

         calculatePkg_C

         calculateCharges

         showBill

Help please!

Explanation / Answer

//functions.h

char getValidPkg();

char getValidHrs();

char calculatePkg_A();

char calculatePkg_B();

char calculatePkg_C();

#include <iostream>

using namespace std;

#include "Header.h"

int main()

{

                char pkg;

                pkg = getValidPkg();

                cout<<"Pkg: "<<pkg<<endl;

               

                int hrs;

                hrs = getValidHrs();

                cout<<"Hrs: "<<hrs<<endl;

               

               

}//endmain

#include <iostream>

using namespace std;

bool isValidPkg(                char p    )                                                                                                                             

{

                return (p>='A' && p<='C') || (p>='a' && p<='c');

}

char getValidPkg()                                                                                                                                                                          

{

                char p=0;

                do

                {

                                cout<<"Enter pkg: ";

                                cin>>p;

                }

                while(   !isValidPkg(p)    );

                return p;

               

}

bool isValidHrs( int h       ){

                return (h>=0 && h<=720);

}

char getValidHrs(){

                int h;

                do

                {

                                cout<<"Enter hours: ";

                                cin>>h;

                }

                while(   !isValidHrs(h)     );

                return h;

}

TRY THIS CODE ALSO MAY HELP U

import java.text.DecimalFormat;

  

public class Assignment02

{

   public static void main(String[] args)

   {

      double hours;   //To hold amount of hours

        char pkg;       //Holds package user has chosen

      String input;   //Holds keyboard input

  

  

      //Create DecimalFormat objects for dollar amounts

      //and percentages.

      DecimalFormat dollar = new DecimalFormat("#,##0.00");

  

      //Create a Scanner object to read input.

      Scanner keyboard = new Scanner(System.in);

  

      System.out.println("This program will ask for "

                         + "information about your internet service package, and calculate your pay.");

      System.out.println("Please enter the following information.");

  

      //Ask user for Package letter

      System.out.println("What package are you currently signed up for?");

      System.out.print("Enter A,B,or C.");

       input = keyboard.nextLine();

      pkg = input.charAt(0); //Get first entered char

  

  

  

         //Determine plan entered.

         switch (pkg)

         {

            case 'a':

            case 'A':

               System.out.println("A");

               break;

            case 'b':

            case 'B':

               System.out.println("B");

               break;

            case 'c':

            case 'C':

               System.out.println("C");

               break;

            default:

               System.out.println("Invalid character.");

        }

  

  

  

      // Ask the user number of hours used.

      System.out.print("Amount of hours: ");

      hours = keyboard.nextDouble();

  

      //Create an instance of the ISP

      //class and pass the data to the constructor.

      ISP payInfo =

         new ISP (hours, pkg);                    //error

  

  

  

      //Display the pay report for the salesperson.

      System.out.println(" Pay Report");

      System.out.println("---------- :3 ----------");

  

      System.out.println("Plan:"

                         +dollar.format(payInfo.getPkg()));

      System.out.println("Total hours:"

                         + dollar.format(payInfo.getHours()));

      System.out.println("Total: $"

                         +dollar.format(payInfo.getTotal()));

  

  

      }

}

//functions.h

char getValidPkg();

char getValidHrs();

char calculatePkg_A();

char calculatePkg_B();

char calculatePkg_C();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote