Problem: Notifications

Write a program, which takes an integer n and on the next rows prints n messages (for each message read a few lines). Each message starts with messageType: success, warning or error:

  • When messageType is success read operation + message (each on a new line).
  • When messageType is warning read only message.
  • When messageType is error read operation + message + errorCode (each on a new line).

Print in the console each read message, formatted depending on its messageType. After the headline of the message print as much =, as the length of the said headline and print an empty line after each message (to understand in detail look at the examples).

The problem should be solved by defining four methods: ShowSuccessMessage(), ShowWarningMessage(), ShowErrorMessage() and ReadAndProcessMessage(), so that only the last method is invoked by the Main() method:

Sample Input and Output

Input Output
credit card purchase
Invalid customer address
Email not confirmed
user registration
User registered successfully
Customer has not email assigned
Error: Failed to execute credit card purchase.
Reason: Invalid customer address.
Error code: 500.

Warning: Email not confirmed.

Successfully executed user registration.
User registered successfully.

Warning: Customer has not email assigned.

Hints and Guidelines

Define and implement the four shown methods.

In ReadAndProcessMessage() read the type of message from the console and according the read type read the rest of the data (one, two or three more lines). After that invoke the method for printing the given type of message.

Testing in the Judge System

Test your solution here:

results matching ""

    No results matching ""