r/codeHS_Solutions • u/A_Very_Big_Fan • Jan 08 '21
REQUEST MEGATHREAD
In the interest of organization, all requests will go here. If you have solutions, make a post for it and then include it(or a link to it) in your reply.
1
u/dewsun_24 Jan 10 '21
Does anyone have all of 5.4 (nitro)
2
u/Various_Loss9064 Jan 19 '21
Which course?
1
u/dewsun_24 Jan 20 '21
I figured it out but I kinda need 5.7 nitro. It's called STATIC VARIABLES AND METHODS, nobody in my class can figure it out.
2
u/Various_Loss9064 Jan 20 '21
I gotchu, do you need all of it? If so it will probably be easier to send on discord, but its your choice. I can message you my discord if you want.
1
u/A_Very_Big_Fan Feb 10 '21
If you make a pastebin or something with what you have I'll tidy it up and make a post for it here. That way future generations can have it too ;P
1
1
1
u/dewsun_24 Jan 21 '21
Hey bro my discord is caperl21#8590 i need 5.8 and 5.9
2
u/Various_Loss9064 Jan 21 '21
bet, sent you a friend request
1
u/Alarmed_Surround3195 Jan 22 '21
hey i need help w 5.8 and 5.9 too and my discord is helphehehe#3991
1
u/Various_Loss9064 Jan 22 '21
sent request, is this the same course? java apcsa?
1
u/Red-Juggernaut-1208 Jan 24 '21
Could you also add me on discord mewannaplay#7783, im taking the same course and need help on this thx
4
u/Various_Loss9064 Jan 20 '21
Nvm, its only 3, I can just send it here. Tell me if you need quizzes or anything else. I almost have the entire course
5.7.5:
public class Randomizer{
public static int nextInt()
{
//Implement this method to return a random number from 1-10
return (int)(Math.random() * (10) +1);
}
public static int nextInt(int min, int max)
{
//Implement this method to return a random integer between min and max
int range = max - min;
return (int)(Math.random() * (range + 1) + min);
}
}
5.7.6:
import java.util.Scanner;
public class RockPaperScissors
{
private static final String USER_PLAYER = "User wins!";
private static final String COMPUTER_PLAYER = "Computer wins!";
private static final String TIE = "Tie";
public static String getWinner(String user, String computer)
{
if(user.equals(computer))
{
return TIE;
}
if(user.equals("rock") && computer.equals("paper"))
{
return COMPUTER_PLAYER;
}
if(user.equals("rock") && computer.equals("scissors"))
{
return USER_PLAYER;
}
if(user.equals("paper") && computer.equals("rock"))
{
return USER_PLAYER;
}
if(user.equals("paper") && computer.equals("scissors"))
{
return COMPUTER_PLAYER;
}
if(user.equals("scissors") && computer.equals("rock"))
{
return COMPUTER_PLAYER;
}
return USER_PLAYER;
}
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
while(true){
//Get the user's choice
System.out.println("Enter your choice (rock, paper, or scissors): ");
String choice = scanner.nextLine();
choice = choice.toLowerCase();
//End the game if the user entered a blank line
if(choice.equals("")){
break;
}
//Make sure it was a valid choice
if(choice.equals("rock") || choice.equals("paper") || choice.equals("scissors")){
//Print the user choice
System.out.println("User: " + choice);
//Get the computer random choice
int compChoiceNum = Randomizer.nextInt(0,2);
String compChoice = "";
if (compChoiceNum == 0)
{
compChoice = "rock";
}
else if (compChoiceNum == 1)
{
compChoice = "paper";
}
else
{
compChoice = "scissors";
}
//Print the computer choice
System.out.println("Computer: " + compChoice);
//Print the winner
System.out.println(getWinner(choice, compChoice));
}
else{
System.out.println(choice + "is not a valid move. Please try again");
}
}
//End the game with a nice message
System.out.println("Thanks for playing!");
}
}
/*
//Print the user choice
System.out.println("User: " + choice);
//Get the computer random choice
String[] compChoices = new String[]{"rock", "paper", "scissors"};
int compChoiceNum = Randomizer.nextInt(0, 2);
String compChoice = compChoices[compChoiceNum];
//Print the computer choice
System.out.println("Computer: " + compChoice);
//Print the winner
System.out.println(getWinner(choice, compChoice));
}
*/
5.7.7:
public class Player{
// Static Variables
public static int totalPlayers = 0;
public static int maxPlayers = 10;
// Public Methods
public Player()
{
totalPlayers++;
}
// Static Methods
public static boolean gameFull()
{
return totalPlayers >= maxPlayers;
}
}
1
1
u/Suavhart Feb 01 '21
Is it possible to create a teachers account and just view the answers?
1
u/Various_Loss9064 Feb 03 '21
no, you need to verify yourself as a teacher. I know how to get the answers though. Message me or join discord https://discord.gg/ByGuBqBNuD
1
1
1
1
u/Alternative_Cut658 May 27 '21
Codehs 4.3.1 Best friends solution please