Balls Bowled – Hands-On C# Cognizant Solution
John want to create a program for calculating the number of balls bowled , if the user enter the number of overs .
Create a class PlayerBO with the method AddOversDetails and GetNoOfBallsBowled .
Create a class Program and get the number of overs from the user and call the AddOversDetails
PlayerBO method signature
public void AddOversDetails(int oversBowled).
public int GetNoOfBallsBowled()
Implement the collection concepts for add overs
Sample Input1 :
Enter the number of overs
50
Sample Output1:
Balls Bowled : 300
Sample Input2 :
Enter the number of overs
25
Sample Output2:
Balls Bowled : 150
BallsBowled.cs
using System; using System.Collections.Generic; namespace BallsBowled //DO NOT change the namespace name { public class Program //DO NOT change the class name { static void Main(string[] args) { //Implement code here Console.WriteLine("Enter the number of overs"); int overs = int.Parse(Console.ReadLine()); PlayerBO pb = new PlayerBO(); pb.AddOversDetails(overs); } } public class PlayerBO //DO NOT change the class name { public List<int> PlayerList { get; set; } = new List<int>(); int balls; public void AddOversDetails(int oversBowled) //DO NOT change the method signature { //Implement code here PlayerList.Add(oversBowled); Console.WriteLine(PlayerList); foreach(int i in PlayerList) { balls = i; } Console.WriteLine("Balls Bowled : " + GetNoOfBallsBowled()); } public int GetNoOfBallsBowled() //DO NOT change the method signature { //Implement code here return balls*6; } } }