Friday, June 3, 2016

URI Online Judge Solution 1114 || Fixed Password

URI Online Judge | 1114

Fixed Password

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Write a program that keep reading a password until it is valid. For each wrong password read, write the message "Senha inválida". When the password is typed correctly print the message "Acesso Permitido" and finished the program. The correct password is the number 2002.

Input

The input file contains several tests cases. Each test case contains only an integer number.

Output

For each number read print a message corresponding to the description of the problem.
Input SampleOutput Sample
2200
1020
2022
2002
Senha Invalida
Senha Invalida
Senha Invalida
Acesso Permitido


URI Online Judge Solution 1114 || Fixed Password in C


#include <stdio.h>

int main()
{
    int number = 1;

    while(number != 2002)
    {
        scanf("%d", &number);
        if(number == 2002){
            printf("Acesso Permitido\n" );
            return 0;
        }else{
            printf("Senha Invalida\n" );
        }

    }

    return 0;
}


URI Online Judge Solution 1114 || Fixed Password in JAVA


import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws IOException {
        int password = 2002, givenPassword;
        Scanner input = new Scanner(System.in);
        while ((givenPassword = input.nextInt()) != password) {
            System.out.print("Senha Invalida\n");
        }
        System.out.print("Acesso Permitido\n");
    }
}

URI Online Judge Solution 1114 || Fixed Password in C++


#include <iostream>

using namespace std;

int main()
{
    int number = 1;

    while(number != 2002)
    {
        cin >> number;
        if(number == 2002){
            cout << "Acesso Permitido" << endl;
            return 0;
        }else{
            cout << "Senha Invalida" << endl;
        }

    }

    return 0;
}




Download code from Dropbox
URI Question link

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.