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

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
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...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing chess himself to practice his abilities. The chess that Jojo played was N × N. When Jojo was practicing, Jojo suddenly saw a position on his chessboard that was so interesting that Jojo tried to put the pieces of Rook, Bishop and Knight in that position. Every time he put a piece, Jojo counts how many other pieces on the chessboard can be captured...
MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write...
MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write a simple assembly language program that performs a few arithmetic operations. This will require you to establish your programming environment and create the capability to assemble and execute the assembly programs that are part of this course. Your \student ID number is a 7-digit number. Begin by splitting your student ID into two different values. Assign the three most significant digits to a variable...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that prompts the user to select a type of coffee she likes and 2) returns the object of what she selected to the console. #include "stdafx.h" #include <iostream> using namespace std; // Product from which the concrete products will inherit from class Coffee { protected:    char _type[15]; public:    Coffee()    {    }    char *getType()    {        return _type;   ...
Book - Introduction to Programming Using Visual Basic 11th Edition by David I. Schneider Programming Language...
Book - Introduction to Programming Using Visual Basic 11th Edition by David I. Schneider Programming Language - Visual Studio 2017 RESTAURANT MENU Write a program to place an order from the restaurant menu in Table 4.13. Use the form in Fig. 4.70, and write the program so that each group box is invisible and becomes visible only when its corresponding check box is checked. After the button is clicked, the cost of the meal should be calculated. (NOTE: The Checked...
Instructions: 1. Please use only C as the language of programming. 2. Please submit the following:...
Instructions: 1. Please use only C as the language of programming. 2. Please submit the following: (1) the client and the server source files each (2) a brief Readme le that shows the usage of the program. 3. Please appropriately comment your program and name all the identifiers suitable, to enable enhanced readability of the code. Problem: Write an ftp client and an ftp server such that the client sends a request to ftp server for downloading a file. The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT