Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package softuni;
- import java.util.Scanner;
- public class SoftUni {
- static void lineMessage(){
- for(int i =0;i<20;i++){
- System.out.print("=");
- }
- System.out.println();
- }
- static void showSuccessMessage(String operation,String message){
- System.out.println("Successfully executed " + operation);
- lineMessage();
- System.out.println(message);
- }
- static void showWarningMessage(String warning){
- System.out.println(warning);
- lineMessage();
- }
- static void showErrorMessage(String error,String reason,int errorCode){
- System.out.println("Error: Failed to execute" + error);
- lineMessage();
- System.out.println("Reason: " + reason);
- System.out.println("Error code: " + errorCode);
- }
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- String type = sc.nextLine().toLowerCase();
- while(type != "success" || type != "warning" || type != "error"){
- if(type.equals("success")){
- System.out.print("Enter the type of the operation: ");
- String operation = sc.nextLine();
- System.out.print("Enter your message: ");
- String message = sc.nextLine();
- showSuccessMessage(operation, message);
- }
- else if(type.equals("warning")){
- System.out.print("Enter your warning");
- String warning = sc.nextLine();
- showWarningMessage(warning);
- }
- else if(type.equals("error")){
- System.out.print("Enter the type of error: ");
- String error = sc.nextLine();
- System.out.print("Enter the reason for the error: ");
- String reason = sc.nextLine();
- System.out.print("Enter the error code: ");
- int errorCode = Integer.parseInt(sc.nextLine());
- showErrorMessage(error, reason, errorCode);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment