MAIN CALL NUM_PLAYERS FOR 1 TO NUM_PLAYERS CALL INPUT CALL COMPUTE END FOR CALL OUTPUT END MAIN FUNCTION NUM_PLAYERS READ number -> You must unsure that number entered is >= 0 END NUM_PLAYERS FUNCTION INPUT -> You must unsure that all numbers entered are >= 0 READ at_bats, singles, doubles, triples, homers END INPUT FUNCTION COMPUTE batting_ave = (singles + doubles + triples + homers)/at_bats slugging_pct = (singles + doubles*2 + triples*3 + homers*4)/at_bats team_at_bats = team_at_bats + at_bats team_hits = team_hits + singles + doubles + triples + homers PRINT "Player #", x, batting_ave, slugging_pct END COMPUTE FUNCTION OUTPUT PRINT team_batting average END OUTPUT
Screenshot
--------------------------------------------
Program
#Method to read number of players in the team
#Check the user input must be positive integer
#It take lst as reference arument
#Append value into list
def NUM_PLAYERS(lst):
n=int(input("Enter number of players: "))
while(n<1):
print("Number of players
must be postive Re=enter")
n=int(input("Enter
number of players: "))
lst.append(n)
#Method to input players details
#Which prompt for batting,singles,doubles,tiple and homers
counts
#Error check the inputs are positive
#Take player number and list a
#Append each values into list
#Which act as reference parameter
def INPUT(playerLst,playerNum):
print("Enter player",playerNum," details")
at_bats=int(input("Enter number of batted:
"))
while(at_bats<1):
print("Batted
count must be postive Re=enter")
at_bats=int(input("Enter number of batted: "))
playerLst.append(at_bats)
singles=int(input("Enter number of singles:
"))
while(singles<1):
print("Singles
count must be postive Re=enter")
singles=int(input("Enter number of singles: "))
playerLst.append(singles)
doubles=int(input("Enter number of doubles:
"))
while(doubles<1):
print("Doubles
count must be postive Re=enter")
doubles=int(input("Enter number of doubles: "))
playerLst.append(doubles)
triples=int(input("Enter number of triples:
"))
while(triples<1):
print("Tripless
count must be postive Re=enter")
doubles=int(input("Enter number of triples: "))
playerLst.append(triples)
homers=int(input("Enter number of homers:
"))
while(homers<1):
print("Homers
count must be postive Re=enter")
doubles=int(input("Enter number of homers: "))
playerLst.append(homers)
#Method to compute each player averages and team average
#Display Player average
#Take two list and player number as input parameter
#Calculated team toal and team hit total and append into list
#Which act as reference
variable
def COMPUTE(playerLst,lst,playerNum):
batting_ave = (playerLst[1] + playerLst[2]
+playerLst[3] + playerLst[4])/playerLst[0]
slugging_pct = (playerLst[1] + playerLst[2]*2
+playerLst[3]*3 + playerLst[4]*4)/playerLst[0]
lst[0] = lst[0] + playerLst[0]
lst[1] = lst[1] + playerLst[1] +
playerLst[2] +playerLst[3] + playerLst[4]
print("Player ",playerNum," batting
average:%.2f"%batting_ave," slugging pct:%.2f"%slugging_pct)
#Method to print team batting average
def OUTPUT(lst):
print("Team batting average:
%.2f"%(lst[1]/lst[0]))
#Main method
#Call each above functions
def main():
lst=[]
NUM_PLAYERS(lst)
numPlayers=lst[0]
lst=[]
lst.append(0)
lst.append(0)
for i in range(1,numPlayers+1):
playerLst=[]
INPUT(playerLst,i)
COMPUTE(playerLst,lst,i)
OUTPUT(lst)
#Program start
main()
-------------------------------------
Output
Enter number of players: 2
Enter player 1 details
Enter number of batted: 10
Enter number of singles: 4
Enter number of doubles: 8
Enter number of triples: 6
Enter number of homers: 7
Player 1 batting average:2.50 slugging pct:6.60
Enter player 2 details
Enter number of batted: 12
Enter number of singles: 8
Enter number of doubles: 9
Enter number of triples: 7
Enter number of homers: 8
Player 2 batting average:2.67 slugging pct:6.58
Team batting average: 2.59
Press any key to continue . . .
----------------------------------------------------------------------------------
Screenshot
------------------------------------
Program
#Create a class
class Student:
#Member variables
Name=""
StudentID=""
GpaHours=0
QualityPoints=0
#Constructor
def __init__(self,name,id,hrs,pnts):
self.Name=name
self.StudentID=id
self.GpaHours=hrs
self.QualityPoints=pnts
#To string method
def __str__(self):
return("StudentName:
"+self.Name+" StudentID: "+self.StudentID+" GpaHours:
"+str(self.GpaHours)+" QualityPoints:
"+str(self.QualityPoints))
#Mutators
def set_GpaHrs(self,hrs):
self.GpaHours=hrs;
def set_QualityPoints(self,pnt):
if(pnts<=(4*self.GpaHours)):
self.QualityPoints=pnt
else:
print("Error!!!!Quality points always less than 4 times of gpa
hours. No change!!!")
#Accessors
def get_GpaHrs(self):
return
self.GpaHours;
def get_QualityPoints(self):
return
self.QualityPoints;
#Gpa calculation method
def CalculateGpa(self):
GPA=0.0
if(self.QualityPoints==0):
print("Divide by zer generate overflow, so return 0")
return GPA
else:
GPA = self.GpaHours /self.QualityPoints
return GPA
#Test
def main():
student=Student("Michael
John","M123",10,30)
print(student)
print("Student
Gpa=%.2f"%(student.CalculateGpa()))
#Star
main()
-------------------------------------
Output
StudentName: Michael John
StudentID: M123
GpaHours: 10
QualityPoints: 30
Student Gpa=0.33
Press any key to continue . . .
For written problems or problems where you are asked to provide an explaination you can submit...
*Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented programming using classes to create objects. PROBLEM DEFINITION: Write a class named Employee that holds the following data about an employee in attributes: name, IDnumber, department, jobTitle The class should have 8 methods as follows: For each attribute, there should be a method that takes a parameter to be assigned to the attribute. This is known as a mutator method. For each...
Must be written in C++ Bank Charges A bank charges $15 per month plus the following check fees for a commercial checking account: $0.10 per check each for fewer than 20 checks (1-19) $0.08 each for 20–39 checks $0.06 each for 40–59 checks $0.04 each for 60 or more checks Write a program that asks for the number of checks written during the past month, then computes and displays the bank’s fees for the month. Input Validation: Display an error...
// Client application class and service class Create a NetBeans project named StudentClient following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. Add a class named Student to the StudentClient project following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans Project your application class StudentC lient should contain the following executable code: package studentclient; public class...
IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand the Application The assignment is to first create a class calledTripleString.TripleStringwill consist of threeinstance attribute strings as its basic data. It will also contain a few instance methods to support that data. Once defined, we will use it to instantiate TripleString objects that can be used in our main program. TripleString will contain three member strings as its main data: string1, string2, and string3....
c++ CSI Lab 6 This program is to be written to accomplish same objectives, as did the program Except this time we modularize our program by writing functions, instead of writing the entire code in main. The program must have the following functions (names and purposes given below). Fot o tentoutefill datere nedefremfite You will have to decide as to what arguments must be passed to the functions and whether such passing must be by value or by reference or...
Using C++. Please Provide 4 Test Cases. Test # Valid / Invalid Data Description of test Input Value Actual Output Test Pass / Fail 1 Valid Pass 2 Valid Pass 3 Valid Pass 4 Valid Pass Question 2 Consider a file with the following student information: John Smith 99 Sarah Johnson 85 Jim Robinson 70 Mary Anderson 100 Michael Jackson 92 Each line in the file contains the first name, last name, and test score of a student. Write a...
In this lab, you complete a partially written Java program that includes methods that require multiple parameters (arguments). The program prompts the user for two numeric values. Both values should be passed to methods named calculateSum(), calculateDifference(), and calculateProduct(). The methods compute the sum of the two values, the difference between the two values, and the product of the two values. Each method should perform the appropriate computation and display the results. The source code file provided for this lab...
(Must be written in Python) You've been asked to write several functions. Here they are: yourName() -- this function takes no parameters. It returns a string containing YOUR name. For example, if Homer Simpson wrote this function it would return "Homer Simpson" quadster(m) -- this function takes a value m that you pass it then returns m times 4. For example, if you passed quadster the value 7, it would return 28. isRratedMovieOK(age) -- this function takes a value age...
java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...
can someone help with this? need to use c++. The aim of this homework assignment is to practice writing classes. This homework assignment will help build towards project I, which will be to write a program implementing Management of Rosters System. For this assignment, write a class called Student. This class should contain information of a single student. This information includes: last name, first name, standing, credits gpa, date of birth, matriculation date. For now you can store date of...