What's new
  • 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 Request IT EXPERT I HAVE A CHALLENGE FOR YOU

Anonyman

Honorary Poster
Established
Joined
May 11, 2018
Messages
755
Reaction score
369
KAILANGAN KO TULONG NYO MGA MASTER PARA SA GRADE KO

1. Write a program that simulates a paper-rock-scissor game. Each users will type in either P,R, or S if the user inputs a wrong letter it must in form the user to input the correct one. the program announce the winner a winner is the player who first obtain the score of 5.

2. create the program that will accept the final grade of 30 students. the program will output the highest and lowest grade among the group then it will output the distribution of grades from 75 to 100


sample input and out
INPUT

Student 1: 89
Student 2: 90
:
:
Student 30: 95

OUTPUT

Student 30 has the highest grade of 95
Student 1 has the lowest grade of 89

Gredes Distribution

below 75:
76-80:**
81-85:
86-90:*
91-95:***
96-100:
 
, Last edited:
A Anonyman ginawa ko yung number 1 problem mo using C#.

Pwede mong i-run yung console app na ginawa ko by clicking You must register or login to view this..

Assuming na may programming knowledge ka na, please aralin mong mabuti kung paano ko siya cinode at magtanong ka lang kung may gusto kang linawin :)

C#:
//Created by PHC-BlackHatNBI
using System;

namespace PaperRockScissorsGame
{
    class Program
    {
        static void Main(string[] args)
        {
            PaperRockScissorGame();
        }

        static void PaperRockScissorGame()
        {
            bool isGameOver = false;
            string chosenLetter, generatedLetter, message;
            int userScore = 0; int enemyScore = 0; int randomNumber = 0;
            Random random = new Random();

            do
            {
                randomNumber = random.Next(1, 4);
                Console.WriteLine("Your score {0} || Enemy's score {1}", userScore, enemyScore);
                Console.WriteLine("Pick your weapon!");
                Console.WriteLine("P: Paper");
                Console.WriteLine("R: Rock");
                Console.WriteLine("S: Scissors");
                chosenLetter = Console.ReadLine();            

                if (randomNumber == 1)
                {
                    generatedLetter = "P";
                }
                else if (randomNumber == 2)
                {
                    generatedLetter = "R";
                }
                else
                {
                    generatedLetter = "S";
                }

                if (chosenLetter.ToUpper() == "P")
                {
                    if (generatedLetter == "P")
                    {
                        message = "Both of you have chosen paper. Pick again!";
                    }
                    else if (generatedLetter == "R")
                    {
                        message = "You have defeated the enemy's rock!";
                        userScore++;
                    }
                    else                          
                    {
                        message = "Enemy's scissors have destroyed your paper!";
                        enemyScore++;
                    }
                }
                else if (chosenLetter.ToUpper() == "R")
                {
                    if (generatedLetter == "P")
                    {
                        message = "Enemy's paper has swollowed your rock!";
                        enemyScore++;
                    }
                    else if (generatedLetter == "R")
                    {
                        message = "Both of you have chosen rock. Pick again!";
                    }
                    else
                    {
                        message = "You have defeated the enemy's scissors!";
                        userScore++;
                    }
                }
                else if (chosenLetter.ToUpper() == "S")
                {
                    if (generatedLetter == "P")
                    {
                        message = "You have defeated the enemy's paper!";
                        userScore++;
                    }
                    else if (generatedLetter == "R")
                    {
                        message = "Enemy's rock has destroyed your scissors!";
                        enemyScore++;
                    }
                    else
                    {
                        message = "Both of you have chosen scissors. Pick again!";
                    }
                }
                else
                {
                    message = "Please choose valid letters only.";
                }

                Console.WriteLine(message);
               
                if (userScore == 5 || enemyScore == 5)
                {
                    Console.WriteLine("Game over. Your score: {0} || Enemy's Score: {1}", userScore, enemyScore);
                    isGameOver = true;
                }
            }
            while (!isGameOver);
        }
    }
}
 

Anonyman

Honorary Poster
A Anonyman ginawa ko yung number 1 problem mo using C#.

Pwede mong i-run yung console app na ginawa ko by clicking You must register or login to view this..

Assuming na may programming knowledge ka na, please aralin mong mabuti kung paano ko siya cinode at magtanong ka lang kung may gusto kang linawin :)

C#:
//Created by PHC-BlackHatNBI
using System;

namespace PaperRockScissorsGame
{
    class Program
    {
        static void Main(string[] args)
        {
            PaperRockScissorGame();
        }

        static void PaperRockScissorGame()
        {
            bool isGameOver = false;
            string chosenLetter, generatedLetter, message;
            int userScore = 0; int enemyScore = 0; int randomNumber = 0;
            Random random = new Random();

            do
            {
                randomNumber = random.Next(1, 4);
                Console.WriteLine("Your score {0} || Enemy's score {1}", userScore, enemyScore);
                Console.WriteLine("Pick your weapon!");
                Console.WriteLine("P: Paper");
                Console.WriteLine("R: Rock");
                Console.WriteLine("S: Scissors");
                chosenLetter = Console.ReadLine();           

                if (randomNumber == 1)
                {
                    generatedLetter = "P";
                }
                else if (randomNumber == 2)
                {
                    generatedLetter = "R";
                }
                else
                {
                    generatedLetter = "S";
                }

                if (chosenLetter.ToUpper() == "P")
                {
                    if (generatedLetter == "P")
                    {
                        message = "Both of you have chosen paper. Pick again!";
                    }
                    else if (generatedLetter == "R")
                    {
                        message = "You have defeated the enemy's rock!";
                        userScore++;
                    }
                    else                         
                    {
                        message = "Enemy's scissors have destroyed your paper!";
                        enemyScore++;
                    }
                }
                else if (chosenLetter.ToUpper() == "R")
                {
                    if (generatedLetter == "P")
                    {
                        message = "Enemy's paper has swollowed your rock!";
                        enemyScore++;
                    }
                    else if (generatedLetter == "R")
                    {
                        message = "Both of you have chosen rock. Pick again!";
                    }
                    else
                    {
                        message = "You have defeated the enemy's scissors!";
                        userScore++;
                    }
                }
                else if (chosenLetter.ToUpper() == "S")
                {
                    if (generatedLetter == "P")
                    {
                        message = "You have defeated the enemy's paper!";
                        userScore++;
                    }
                    else if (generatedLetter == "R")
                    {
                        message = "Enemy's rock has destroyed your scissors!";
                        enemyScore++;
                    }
                    else
                    {
                        message = "Both of you have chosen scissors. Pick again!";
                    }
                }
                else
                {
                    message = "Please choose valid letters only.";
                }

                Console.WriteLine(message);
              
                if (userScore == 5 || enemyScore == 5)
                {
                    Console.WriteLine("Game over. Your score: {0} || Enemy's Score: {1}", userScore, enemyScore);
                    isGameOver = true;
                }
            }
            while (!isGameOver);
        }
    }
}
Maraming salamat paps kaso kailangan raw paps 2 player at tsaka java scanner lng raw gamitin pero salamat parin paps sa effort mo
 

Anonyman

Honorary Poster
May challenge din ako sayo TS. Gawa mo ng program tapos ipost mo dito. 😁
Ayan code ko oh kaso na stock ako Kung paano mag announce Ng winner kapag naka 5 correct ang
import java.util.Scanner; import java.io.*;

public class Part2 {

public static void main (String[]args)
{
Scanner scan = new Scanner(System.in);

String userInput1 = " ";
char player1Input;

String userInput2 = " ";
char player2Input;

for(int i = 0; i < 5; i++) //Loop for game
{

System.out.println("Player 1: Please Enter e.g R for Rock:");
System.out.println("R.Rock");
System.out.println("P.Paper");
System.out.println("S.Scissors");

userInput1 = scan.next();
player1Input = userInput1.charAt(0);


System.out.println("Player 2: Please Enter e.g S for Scissors");
System.out.println("R.Rock");
System.out.println("P.Paper");
System.out.println("S.Scissors");



userInput2 = scan.next();
player2Input = userInput2.charAt(0);

}





switch(player1Input)
{
case 'R': System.out.println ("Player 1:Rock");

switch(player2Input)
{
case'R' : System.out.println("Player 2:Rock");
System.out.println("The Game Result is Draw");
break;
case'P' :System.out.println("Player 2:paper");
System.out.println("The Game Result is: Player 2 Wins");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println("The Game Result is: Player 1 Wins");
break;
default: System.out.println("Invalid Option");
break;
}
break;

case 'P' : System.out.println ("Player 1:paper");
switch(player2Input)
{
case'R' : System.out.println("Player 2:Rock");
System.out.println("The game result is: Player 1 Wins");
break;
case'P' :System.out.println("Player 2:paper");
System.out.println("The game result is: Draw");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println("The Game Result is: Player 2 Wins2");
break;
default: System.out.println("Invalid Option");
break;
}
break;

case 'S' : System.out.println ("Player 1:Scissors");
switch(player2Input)
{
case'R' : System.out.println("Player 2:Rock");
System.out.println("The Game Result is: Player 2 Wins");
break;
case'P' :System.out.println("Player 2:paper");
System.out.println("The game result is: Player 1 Wins");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println ("The Game Result is: Draw");
break;
default: System.out.println("Invalid Option");
break;
}
break;

}
}
}
May challenge din ako sayo TS. Gawa mo ng program tapos ipost mo dito. 😁
Ayan Yung code ko oh kaso stock ako Kung paano mag announce Ng winner kapag naka 5 correct answer na Yung player

import java.util.Scanner; import java.io.*;

public class Part2 {

public static void main (String[]args)
{
Scanner scan = new Scanner(System.in);

String userInput1 = " ";
char player1Input;

String userInput2 = " ";
char player2Input;

for(int i = 0; i < 5; i++) //Loop for game
{

System.out.println("Player 1: Please Enter e.g R for Rock:");
System.out.println("R.Rock");
System.out.println("P.Paper");
System.out.println("S.Scissors");

userInput1 = scan.next();
player1Input = userInput1.charAt(0);


System.out.println("Player 2: Please Enter e.g S for Scissors");
System.out.println("R.Rock");
System.out.println("P.Paper");
System.out.println("S.Scissors");



userInput2 = scan.next();
player2Input = userInput2.charAt(0);

}





switch(player1Input)
{
case 'R': System.out.println ("Player 1:Rock");

switch(player2Input)
{
case'R' : System.out.println("Player 2:Rock");
System.out.println("The Game Result is Draw");
break;
case'P' :System.out.println("Player 2:paper");
System.out.println("The Game Result is: Player 2 Wins");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println("The Game Result is: Player 1 Wins");
break;
default: System.out.println("Invalid Option");
break;
}
break;

case 'P' : System.out.println ("Player 1:paper");
switch(player2Input)
{
case'R' : System.out.println("Player 2:Rock");
System.out.println("The game result is: Player 1 Wins");
break;
case'P' :System.out.println("Player 2:paper");
System.out.println("The game result is: Draw");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println("The Game Result is: Player 2 Wins2");
break;
default: System.out.println("Invalid Option");
break;
}
break;

case 'S' : System.out.println ("Player 1:Scissors");
switch(player2Input)
{
case'R' : System.out.println("Player 2:Rock");
System.out.println("The Game Result is: Player 2 Wins");
break;
case'P' :System.out.println("Player 2:paper");
System.out.println("The game result is: Player 1 Wins");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println ("The Game Result is: Draw");
break;
default: System.out.println("Invalid Option");
break;
}
break;

}
}
}
 

mrHazan

Eternal Poster
Code:
public void main()
{
    1. Get input of player 1 - R, P, S
    2. Get input of player 2 or random - R, P, S

    if(input1 == input2)
    {
        //Draw
    }
    else
    {
        if(input1 is S and input2 is R
        or input1 is R and input2 is P
        or input1 is P and input2 is S)
        {
            //Lose
            //Add point to player 2
        }
        else
        {
            //win
            //Add point to player 1
        }
    }

    if(scorePlayer1 == 5)
    {
        //You win
        //End
    }
    else if (scorePlayer2 == 5)
    {
        //You lose
        //End
    }
    
    Repeat (While)
}
Yan yung short idea. Wag maraming if else.
 

J_M_R

ダーク
Gusto ko sana sagutin yan kahit sa isang thread niya kaso tagal ko na hindi nag java need ko pa aralin syntax, masasagot ko yan sa javascript at html. Anyway meron na nakasagot at nagbigay ng ideas.
Sad naman sige sorry
 

Anonyman

Honorary Poster
Code:
public void main()
{
    1. Get input of player 1 - R, P, S
    2. Get input of player 2 or random - R, P, S

    if(input1 == input2)
    {
        //Draw
    }
    else
    {
        if(input1 is S and input2 is R
        or input1 is R and input2 is P
        or input1 is P and input2 is S)
        {
            //Lose
            //Add point to player 2
        }
        else
        {
            //win
            //Add point to player 1
        }
    }

    if(scorePlayer1 == 5)
    {
        //You win
        //End
    }
    else if (scorePlayer2 == 5)
    {
        //You lose
        //End
    }
    
    Repeat (While)
}
Yan yung short idea. Wag maraming if else.
paano Yan paps
 
Top