0

Grow Your business. I need help.

The task is: "A company has 2 departments and it is growing, so more departments are needed. The program you are given takes the number of departments to be opened as input, then takes their names and creates Department objects, passing their names as the constructor. Complete the Department class to have 1 static member depCount with an initial value of 2 for the number of departments and the constructor that will count it and output corresponding message (see sample output). Sample Input 2 Finance Marketing Sample Output Department opened: Finance Department opened: Marketing Number of departments: 4 Here is my code: https://www.sololearn.com/compiler-playground/cK3EGT6U3Ol6

22nd Feb 2023, 2:27 AM
chaodis
3 Respuestas
+ 1
chaodis here is your code-bit to help others to help you.. https://code.sololearn.com/cK3EGT6U3Ol6/?ref=app
22nd Feb 2023, 2:56 AM
BroFar
BroFar - avatar
+ 1
chaodis using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int numOfDeps = Convert.ToInt32(Console.ReadLine()); int count = 0; int totDep =(int)Department.depCount + numOfDeps; while (count < numOfDeps) { string depName = Console.ReadLine(); Department dep = new Department(depName); count++; } Console.WriteLine("Number of departments: " + totDep); } } class Department { public string depName; public static int depCount=2; //declare static depCount member with value of 2 //complete the constructor public Department(string name) { Console.WriteLine("Department opened: " + name); this.depName = name; } } }
22nd Feb 2023, 3:59 AM
BroFar
BroFar - avatar
+ 1
Thank you Brofar this is amazing thank you!
23rd Feb 2023, 11:40 PM
chaodis