Answered! CPS 180 Lab Assignment #6: Team Game Scoring Assignment Due: 06/09/17 Assigned: 06/02/17 Points: 40 Create…

CPS 180 Lab Assignment #6: Team Game Scoring Assignment Due: 06/09/17 Assigned: 06/02/17 Points: 40 Create a Java program to simulate some 2 team game. Ask the user to input the following information: gN Game Name tIN Team 1 ame t2N Team 2 Name nP of periods (quarters, innings, periods) sV-points per score choose one, even if game has multiple scores (i.e. football) SN Score Name pN Period Name The program should work for any game such as football, baseball hockey, basketball, soccer, etc. 1. Use appropriate variable names and data types for these inputs. 2. Also create variables to accumulate the scores for each respective team, such as teamiscore, team2Score. 3. Input data for the 7 variables from the user. 4. Set up a counter controlled loop to go through the periods from 1..nP. 5. Tally the points for each team, then report the results, along with the winner, or if it were a tie. Create data validation loops for the 2 numeric inputs (range check for 1 through 7). 6. Provide 3 sets of sample output. Store the files in a .zip (not a .7zip or rar). Here is an example of Sample output: Please Enter Game Name: Football Dolphins Please Enter Football Team l Name: Please Enter Football Team 2 Name: Chargers Touchdown What is a score in Football called?
media%2F4fd%2F4fd01cc7-0fe9-4c09-9662-83

CPS 180 Lab Assignment #6: Team Game Scoring Assignment Due: 06/09/17 Assigned: 06/02/17 Points: 40 Create a Java program to simulate some 2 team game. Ask the user to input the following information: gN Game Name tIN Team 1 ame t2N Team 2 Name nP of periods (quarters, innings, periods) sV-points per score choose one, even if game has multiple scores (i.e. football) SN Score Name pN Period Name The program should work for any game such as football, baseball hockey, basketball, soccer, etc. 1. Use appropriate variable names and data types for these inputs. 2. Also create variables to accumulate the scores for each respective team, such as teamiscore, team2Score. 3. Input data for the 7 variables from the user. 4. Set up a counter controlled loop to go through the periods from 1..nP. 5. Tally the points for each team, then report the results, along with the winner, or if it were a tie. Create data validation loops for the 2 numeric inputs (range check for 1 through 7). 6. Provide 3 sets of sample output. Store the files in a .zip (not a .7zip or rar). Here is an example of Sample output: Please Enter Game Name: Football Dolphins Please Enter Football Team l Name: Please Enter Football Team 2 Name: Chargers Touchdown What is a score in Football called?

Expert Answer

 Game.java

import java.util.Scanner;
public class Game
{
public static void main(String a[])
{
String gameName,team1Name,team2Name,scoreName,periodName;
int pointsPerScore,noOfQuarters,totalTeam1Score=0,totalTeam2Score=0;
Scanner input = new Scanner(System.in);
System.out.print(“Please Enter Game Name:”);
gameName = input.next();
System.out.print(“nPlease Enter “+gameName+” Team 1 Name:”);
team1Name = input.next();
System.out.print(“nPlease Enter “+gameName+” Team 2 Name:”);
team2Name = input.next();
System.out.print(“nWhat is a score in “+gameName+” called?”);
scoreName = input.next();

System.out.print(“nHowmany points per “+scoreName+” in “+gameName+”?”);
pointsPerScore = input.nextInt();

System.out.print(“nWhat is a period in “+gameName+” called?”);
periodName = input.next();
System.out.print(“nHowmany Quarters in “+gameName+”?”);
noOfQuarters = input.nextInt();
for(int i=1;i<=noOfQuarters;i++)
{
System.out.print(“nQuarter#”+i+”:nHowmany “+scoreName+”s for “+team1Name+”?”);
int score1 = input.nextInt();
totalTeam1Score+=score1;
System.out.print(“nHowmany “+scoreName+”s for “+team2Name+”?”);
int score2 = input.nextInt();
totalTeam2Score+=score2;
}
System.out.print(“n”+gameName+” Game Results:n——————————-“);
System.out.print(“n”+team1Name+” scored “+totalTeam1Score+” “+scoreName+”s for a score of “+totalTeam1Score*pointsPerScore);

System.out.print(“n”+team2Name+” scored “+totalTeam2Score+” “+scoreName+”s for a score of “+totalTeam2Score*pointsPerScore);
if(totalTeam1Score > totalTeam2Score)
System.out.print(“n”+team1Name+”s Win by “+(pointsPerScore*(totalTeam1Score-totalTeam2Score))+” points!”);
else if(totalTeam1Score < totalTeam2Score)
System.out.print(“n”+team2Name+”s Win by “+(pointsPerScore*(totalTeam2Score-totalTeam1Score))+” points!”);
else
System.out.println(“n Both Teams were in Tie!!!”);
}
}

Still stressed from student homework?
Get quality assistance from academic writers!