1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

Help patulong po

Discussion in 'Coding, Programming' started by JanJZ, Aug 26, 2015.

  1. hello sa inyo first year student ako sa BS IT.. patulong sa program code nito... masakit na kasi ulo sa kakasolve nito,,

    1 write a program that determines if the input letter is a Vowel or Consonant. the Vowels are: A E I O U.
    Your program must able to handle a capital or small input letter.

    2 write a program that determines the class of the ship depending on it's class ID (identifier). here are the criteria. the class ID serves as the input data and the Ship as the output information.
    1. class ID Ship Class
    2. B or b Battleship
    3. C or c Cruiser
    4. D or d Destroyer
    5. F or f Frigate

    maraming salamat....
     
    Last edited: Aug 26, 2015
  2. Yiskha

    Yiskha Forum Veteran Established

    anung language ba gamit mo c+ or c#
     
    JanJZ likes this.
  3. jpotz

    jpotz Support Team Staff Member Support Team

    anu pwede mong gamitin na prog. languange?
     
    JanJZ likes this.
  4. c++
     
  5. c++
     
  6. Yiskha

    Yiskha Forum Veteran Established

    try mo to sa question number 1



    #include<stdio.h>
    int main(){
    char c;
    printf("Enter an alphabet: ");
    scanf("%c",&c);
    if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U')
    printf("%c is a vowel.",c);
    else
    printf("%c is a consonant.",c);
    return0;
    }
     
    JanJZ likes this.
  7. salamat :)
    cge try ko
     
  8. Yiskha

    Yiskha Forum Veteran Established

    2nd question try mo to



    //Connecting library
    #include <iostream>
    using namespace std;
    int main()
    {
    char ch;
    cout<<"Enter the class ID: "<<endl;
    cin>>ch;
    switch(ch)
    {
    case 'B':
    {
    cout<<endl<<"Battle ship";
    break;
    }
    case 'b':
    {
    cout<<endl<<"Battle ship";
    break;
    }
    case 'C':
    {
    cout<<endl<<"Cruiser";
    break;
    }
    case 'c':
    {
    cout<<endl<<"Cruiser";
    break;
    }
    case 'D':
    {
    cout<<endl<<"Destroyer";
    break;
    }
    case 'd':
    {
    cout<<endl<<"Destroyer";
    break;
    }
    case 'F':
    {
    cout<<endl<<"Frigate";
    break;
    }
    case 'f':
    {
    cout<<endl<<"Frigate";
    break;
    }
    default:break;
    }
    //system("pause");
    return 0;
    }
     
    JanJZ likes this.
  9. maraming salamat ulit
     
  10. 1. Write a scissor - rock - paper game commonly known as "jack n poy" in the Philippines (our beloved country).
    Two players will input the first equivalent letter, for example, s for scissor, r for rock, and p for paper. then display
    the winner and the basis of winning such as: paper covers rock, rock beats scissor, and scissor cuts paper or nobody
    wins. Capital or small letters should be accepted by your program.

    2. write a program for the Air Force to label an aircraft as military or civilian. the program is to be given the plane's
    observed speed in km/h and it's estimated length in meters. for planes travelling in excess of 1100 km/h, and longer
    than 52 meters, you should label them as "Civilian" aircraft, and shorter such as 500 km/h and 20 meters as
    "Military" aircraft. for planes travelling at more slower speeds, you will issue an "It's a bird" message.
     
  11. Yiskha

    Yiskha Forum Veteran Established

    Number 1

    // Rock Paper Scissors

    #include <iostream>
    #include<cstdlib>
    #include<ctime>

    using namespace std;

    int main() {
    enum choice {ROCK, PAPER, SCISSORS};

    choice select;
    char user;
    bool play_again;
    string play;
    int num_games = 0;
    int player_wins = 0;
    int computer_wins = 0;
    bool tie = false;
    int num_ties = 0;

    // Ask the user if they would like to play.
    cout << "Would you like to play Rock, Paper, Scissors? (y or n): ";
    cin >> play;

    // If they answer yes, then play, otherwise no.
    if(play == "y" || play == "Y"){
    play_again = true;
    num_games++;
    }

    // Start playing the actual game if they want to play.
    while(play_again != false){
    cout << endl << endl << "Rock, Paper, or Scissors? ('r', 'p', or 's'): " ;
    cin >> user;
    cout << endl;

    // Taking the input and applying it to constant in enum.
    if (user == 'r' || user == 'R'){
    select = ROCK;
    }

    else if (user == 'p' || user == 'P'){
    select = PAPER;
    }

    else if (user == 's' || user == 'S'){
    select = SCISSORS;
    }

    else {
    cout << "Come on... That's not an option." << endl;
    cout << endl << endl << "Rock, Paper, or Scissors? ('r', 'p', or 's'): " ;
    cin >> user;
    }


    long seed = time(NULL); // gets current time
    srand(seed);

    // Computer's random selection
    int computer = rand();

    //DEBUG: cout << computer << endl;

    // Computer's random selection
    computer = rand() % 3;

    //DEBUG: cout << computer << endl << endl;;
    //DEBUG: cout << "Here is a test: " << select << endl;


    // Applying the computer's selection to the appropriate value in enum.
    choice cpu_select;

    if (computer == 0){
    cpu_select = ROCK;
    }

    else if (computer == 1){
    cpu_select = PAPER;
    }

    else if (computer == 2){
    cpu_select = SCISSORS;
    }

    // In the even of a tie. [This creates an infinite loop if there is ever a tie for some reason.]

    /*
    if (cpu_select == select){
    tie = true;
    }

    while(tie == true){
    cout << endl << "It's a tie, Pick again please: ";
    cin >> user;

    if(cpu_select != select)
    tie = false;
    }
    */

    // Displays each respective selection.
    cout << endl << endl << "Your selection is " << select << endl;
    cout << "The computer selects " << cpu_select << endl;

    bool you_win = false;


    // Win conditions

    if ((select == ROCK && cpu_select == SCISSORS) || (select == PAPER && cpu_select == ROCK) || (select == SCISSORS && cpu_select == PAPER)){
    cout << endl << "You win." << endl;
    player_wins ++;
    }

    else if((cpu_select == ROCK && select == SCISSORS) || (cpu_select == PAPER && select == ROCK) || (cpu_select == SCISSORS && select == PAPER)){
    cout << endl << "The computer wins." << endl;
    computer_wins ++;
    }

    else if (cpu_select == select){
    num_ties++;
    }


    // Show the results of all the games.
    cout << endl << "You have won " << player_wins << " games." << endl;
    cout << "The computer has won " << computer_wins << " games." << endl;
    cout << endl << "There have been " << num_ties << " ties." << endl;

    // Ask if the player would like to play again.
    cout << endl << endl << "Would you like to play again?: ";
    cin >> play;

    // Exit the loop if the player chooses no.
    if (play == "n" || play == "N"){
    play_again = false;
    }
    else if (play == "y" || play == "Y"){
    num_games++;
    }

    }

    // DEBUG: Shows number of games played.
    cout << endl << "You just played " << num_games << " games of Rock Paper Scissors." << endl << endl;



    system("pause");
    return 0;

    }
     
    JanJZ likes this.
  12. Yiskha

    Yiskha Forum Veteran Established

    Number 2

    Answer
    #include &lt;stdlib.h&gt;
    #include &lt;iostream&gt; &nbsp;// for cout and cin
    #include &lt;stdio.h&gt;
    #include &lt;cstdlib&gt; &nbsp; // for system
    using namespace std;
    int main()
    {
    int speed;
    int length;
    cout&lt;&lt;&quot;enter the aircraft&#039;s speed and length&quot;&lt;&lt;endl;
    cin&gt;&gt;speed&gt;&gt;length;
    if (speed &gt; 1100 &amp;&amp; length &gt; 52) cout&lt;&lt;&quot;civilian aircraft&quot;&lt;&lt;endl;
    else
    {
    if(speed &lt; 500 ) cout&lt;&lt;&quot;It is a bird&quot;&lt;&lt;endl;
    else
    cout&lt;&lt;&quot;military aircraft&quot;&lt;&lt;endl;
    }
    system(&quot;pause&quot;);
    return 0;
    }
     
    JanJZ likes this.
Tags / Keywords: