Question

In: Computer Science

Objectives: 1. To get familiar with C# programming language 2. To get familiar with Visual Studio...

Objectives:
1. To get familiar with C# programming language
2. To get familiar with Visual Studio development environment
3. To practice on writing a C# program
Task 1: Create documentation for the following program which includes the following:
a. Software Requirement Specification (SRS)
b. Use Case
Task 2: Write a syntactically and semantically correct C# program that models telephones. Your program has to be
a C# Console Application. You will not implement classes in this program other than the class which runs the main
method.
The main() method
Use a do while loop to prompt for telephone data by calling an inputPhone( ) method which you will implement and
is explained below. Please do not change the signature of the method!
You will need parallel arrays to telephone data.
Once done with data entry, output the telephone data stored in arrays by invoking an outputPhones( ) method as
described below. Again, do not change the signature of the method!
The inputPhone() method
The method signature is
static void inputPhone(ref string manufacturer, ref string model,
ref bool hasCord, ref double price)
It prompts the user for the telephone manufacturer’s name, phone model, price and whether it has a cord (refer to
the sample run output below). Store the entered values in the parameters. You may use Convert.ToDouble( ) to
convert a string to a double number.
Have you noticed that all parameters are reference parameters?
The outputPhones() method
The method signature is
static void outputPhones(string [] manufacturers, string [] models,
bool [] hasCords, double [] prices, int numberOfPhones)
The last parameter contains the number of the telephones to be displayed.
You code need to output the heading, and use a for loop to output the telephone data stored in the arrays passed to
the method. The format of the output is shown in the sample run output.
Refer to the sample run output for details.
Note: Please follow the coding style of C#


Deliverables:

Sample Output:


Enter the Phone Manufacturer: VTech
Enter the Phone Model: V3399
Is it cordless? [Y or N]: y
Enter the Phone Price: $49.99
Would like to process another phone? [Y or N]: Y
Enter the Phone Manufacturer: AT&T
Enter the Phone Model: T-9898
Is it cordless? [Y or N]: N
Enter the Phone Price: $29.98
Would like to process another phone? [Y or N]: y
Enter the Phone Manufacturer: Panasonic
Enter the Phone Model: P 4321
Is it cordless? [Y or N]: Y
Enter the Phone Price: $98.97
Would like to process another phone? [Y or N]: n
Output of Telephones
=== Phone #1 ===
Manufacturer: VTech
Model: V3399
Cordless: Yes
Price: $49.99
=== Phone #2 ===
Manufacturer: AT&T
Model: T-9898
Cordless: No
Price: $29.98
=== Phone #3 ===
Manufacturer: Panasonic
Model: P 4321
Cordless: Yes
Price: $98.97
A total of 3 telephones
Press any key to continue . . .

Solutions

Expert Solution

Screenshot

Program

using System;
using System.Collections.Generic;
namespace TelephoneModels
{
    class Program
    {
        //Main method
        static void Main(string[] args)
        {
            //Variables for user input
            char ch=' ';
            string manufacturer="", model="";
            double price=0;
            bool hasCord=false;
            //Storage arrays
            string[] manufactureDetails, modelDetails;
            double[] priceDetails;
            bool[] hascordDetails;
            //List use for getting dynamic arrays
            List<string> man = new List<string>(), mod = new List<string>();
            List<double> pr=new List<double>();
            List<bool> cord=new List<bool>();
            //Loop until user wishes
            do
            {
                //Call function to get input from user
                inputPhone(ref manufacturer,ref model,ref hasCord,ref price);
                Console.Write("Would like to process another phone?[Y or N]: ");
                man.Add(manufacturer);
                mod.Add(model);
                pr.Add(price);
                cord.Add(hasCord);
                ch = Console.ReadKey().KeyChar;
                Console.WriteLine();
            } while (ch == 'y' || ch == 'Y');
            //Convert into array
            manufactureDetails = man.ToArray();
            modelDetails = mod.ToArray();
            priceDetails = pr.ToArray();
            hascordDetails = cord.ToArray();
            //Call method to display output
            outputPhones(manufactureDetails, modelDetails, hascordDetails, priceDetails, manufactureDetails.Length);
        }
        //Method to get input of phone details from user
        //Prompt for each details and add correspoding values into reference variables
        static void inputPhone(ref string manufacturer, ref string model, ref bool hasCord, ref double price)
        {
            Console.Write("Enter the Phone Manufacturer: ");
            manufacturer = Console.ReadLine();
            Console.Write("Enter the Phone Model: ");
            model = Console.ReadLine();
            Console.Write("Is it cordless? [Y or N]: ");
            char isCord = Console.ReadKey().KeyChar;
            if (isCord == 'Y' || isCord == 'y')
            {
                hasCord = true;
            }
            else
            {
                hasCord = false;
            }
            Console.Write("\nEnter the Phone Price: $");
            price = Convert.ToDouble(Console.ReadLine());
        }
        //Function to display phone etails
        static void outputPhones(string[] manufacturers, string[] models,bool[] hasCords, double[] prices, int numberOfPhones)
        {
            int cntr = 1;
            Console.WriteLine("Output of Telephones");
            for(int i = 0; i < numberOfPhones; i++)
            {
                Console.WriteLine("=== Phone #" + cntr + " ===");
                Console.WriteLine("Manufacturer: " + manufacturers[i]);
                Console.WriteLine("Model: " + models[i]);
                if (hasCords[i])
                {
                    Console.WriteLine("Cordless: Yes");
                }
                else
                {
                    Console.WriteLine("Cordless: No");
                }
                Console.WriteLine("Price: $" + prices[i]);
                cntr++;
            }
            Console.WriteLine("A total of " + numberOfPhones + " telephones");
        }
    }
}

---------------------------------------------

Output

Enter the Phone Manufacturer: VTech
Enter the Phone Model: V3399
Is it cordless? [Y or N]: y
Enter the Phone Price: $49.99
Would like to process another phone?[Y or N]: y
Enter the Phone Manufacturer: At&T
Enter the Phone Model: T-9898
Is it cordless? [Y or N]: n
Enter the Phone Price: $29.98
Would like to process another phone?[Y or N]: y
Enter the Phone Manufacturer: Panasonic
Enter the Phone Model: P 4321
Is it cordless? [Y or N]: y
Enter the Phone Price: $98.97
Would like to process another phone?[Y or N]: n
Output of Telephones
=== Phone #1 ===
Manufacturer: VTech
Model: V3399
Cordless: Yes
Price: $49.99
=== Phone #2 ===
Manufacturer: At&T
Model: T-9898
Cordless: No
Price: $29.98
=== Phone #3 ===
Manufacturer: Panasonic
Model: P 4321
Cordless: Yes
Price: $98.97
A total of 3 telephones
Press any key to continue . . .


Related Solutions

Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is...
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is a sub class is derived from the Account class and implements the ITransaction interface. There are two class variables i.e. variables that are shared but all the objects of this class. A short description of the class members is given below: CheckingAccount Class Fields $- COST_PER_TRANSACTION = 0.05 : double $- INTEREST_RATE = 0.005 : double - hasOverdraft: bool Methods + «Constructor» CheckingAccount(balance =...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some time and still can't quite figure it out. I'm creating an app that has 2 textboxes, 1 for inputting customer name, and the second for entering the number of tickets the customer wants to purchase. There are 3 listboxes, the first with the days of the week, the second with 4 different theaters, and the third listbox is to display the customer name, number...
Write a C-based language program in visual studio that uses an array of structs that stores...
Write a C-based language program in visual studio that uses an array of structs that stores student information including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,”). Write the same program in the same language without using structs.
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P2. For example, a student with first name John and Last name Smith would name the project A1JohnSmithP2. Write a C# (console) program to calculate the number of shipping labels that can be printed on a sheet of paper. This program will use a menu...
This is a discussion question for my csc 252 computer programming c++ visual studio so post...
This is a discussion question for my csc 252 computer programming c++ visual studio so post in c++ visual studio so that i can copy and paste thank you. In Object Oriented Programming, classes represent abstractions of real things in our programs. We must quickly learn how to define classes and develop skills in identifying appropriate properties and behaviors for our class. To this end, pick an item that you work with daily and turn it into a class definition....
Create a question bank. The language is visual studio c++. Description: Question bank computerizes the MCQ...
Create a question bank. The language is visual studio c++. Description: Question bank computerizes the MCQ based exams.It takes input from a file having questions and their answers and presents randomly before the exam takers. Required skill set: OOP, STL(Vector), Arrays and file handling
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that serves as a healthcare billing management system. This application is a multiform project (Chapter 9) with three buttons. The "All Accounts" button allows the user to see all the account information for each patient which is stored in an array of class type objects (Chapter 9, section 9.4).The "Charge Service" button calls the Debit method which charges the selected service to the patient's account...
Kindly Do the program in C++ language Object Oriented Programming. Objectives  Implement a simple class...
Kindly Do the program in C++ language Object Oriented Programming. Objectives  Implement a simple class with public and private members and multiple constructors.  Gain a better understanding of the building and using of classes and objects.  Practice problem solving using OOP. Overview You will implement a date and day of week calculator for the SELECTED calendar year. The calculator repeatedly reads in three numbers from the standard input that are interpreted as month, day of month, days...
Complete the following assignment in C programming language. Get the user’s first name and store it...
Complete the following assignment in C programming language. Get the user’s first name and store it to a char array Declare a character array to hold at least 20 characters. Ask for the user’s first name and store the name into your char array. Hint: Use %s for scanf. %s will only scan one word and cannot scan a name with spaces. Get 3 exam scores from the user: Declare an array of 3 integers Assume the scores are out...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT