Prompts the user to enter the amount of data (in gigabytes) they have used in a month.

Write a pseudocode that:

Calculates the remaining data from a 50GB monthly allowance.
Displays the remaining data to the user.

The Correct Answer and Explanation is:

Pseudocode:

BEGIN
    CONSTANT MONTHLY_ALLOWANCE = 50

    DISPLAY "Enter the amount of data used this month (in GB):"
    INPUT dataUsed

    IF dataUsed <= MONTHLY_ALLOWANCE THEN
        remainingData = MONTHLY_ALLOWANCE - dataUsed
        DISPLAY "You have", remainingData, "GB of data remaining."
    ELSE
        overUsage = dataUsed - MONTHLY_ALLOWANCE
        DISPLAY "You have exceeded your data limit by", overUsage, "GB."
    ENDIF
END

This pseudocode is designed to simulate a simple data usage tracker for a monthly internet plan with a fixed allowance of 50 gigabytes (GB). The objective is to prompt the user for the amount of data they’ve used during the month, calculate the remaining data (or overage), and display the appropriate message.

The program begins by defining a constant MONTHLY_ALLOWANCE, which is set to 50 GB. This is the maximum data limit the user is allowed to consume each month under their plan.

Next, the program prompts the user to input how much data they have used (dataUsed). This step represents a form of user interaction where the individual inputs the data usage figure. The INPUT keyword captures this user-provided value and stores it in the variable dataUsed.

The program then uses an IF-THEN-ELSE control structure to determine whether the user has stayed within their data allowance or exceeded it:

  • If dataUsed is less than or equal to the 50GB limit, the program subtracts the used data from the total allowance and stores the result in remainingData. It then displays this value to the user, informing them how much data they have left for the month.
  • If the user has used more than 50GB, the program calculates how much they went over by subtracting 50GB from dataUsed, storing the excess in overUsage. It then displays a message warning the user that they have exceeded their data cap.
Scroll to Top