Objective: Learn basic C# Programming Language
A certain automobile dealership sells fifteen different models of automobiles and employs ten salesmen.
A record of sales for each month can be represented by a table, the first row of which contains the
number of sales of each model by salesman 1, the second row contains the number of sales of each
model by salesman 2, and so on. For example, suppose that the sales table for a certain month is the
following:
0 0 2 0 5 6 3 1 3 4 3 3 1 0 2
5 1 9 0 0 2 3 2 2 3 1 4 6 2 1
0 0 0 1 0 0 0 3 1 6 2 1 7 3 2
1 1 1 0 2 2 2 5 2 7 4 2 8 2 1
5 3 2 0 0 0 5 2 1 2 6 6 6 1 4
4 2 1 0 1 1 0 4 4 1 5 5 1 2 1
3 2 5 0 1 2 0 1 3 5 4 3 2 1 2
3 0 7 1 3 5 1 0 6 8 2 2 3 2 1
0 2 6 1 0 2 2 1 1 2 1 5 4 3 0
4 0 2 3 2 1 3 2 3 1 5 4 0 1 0
Figure 1
The automobile models are defined as follows.
Camry, Corolla, Tercel, Protege, Mazda3, Mazda6,Altima, Maxima,
Sentra, Diamante, colt, Mirage, Legacy, Stylus, Impulse.
A Console Based C# program to be written to accomplish the following requirements:
1.The C# program must manage data using a 2-Dimensional array of integers (table in figure 1).
2.The program must be menu driven (See Figure 2)
Your system should be menu driven with the following options.
General Auto Sales
==================
1.Add a new sale
2.Sales Per Salesman by model
3.All Sales Per Salesman
4.All Sales For The Company
5.Exit
Figure 2
1.Add a new sale. When this option is selected a screen is popped up requesting the following
information.
Enter Transaction Code :
A transaction code is a 4 character string. For example 0912 is a valid transaction code. The first two
characters represent the salesman code , and the last two characters represent the automobile model
code. Once the transaction code is entered at the above prompt, a verification is required check if the
entered code is a valid one. If the code is invalid then an error message is displayed. If the
entered code is a valid one, the value of the (9,12) location of the table must be incremented by 1.
[Note: In C#, array indices start from 0. Therefore 0, 0 location is a valid location for a 2-D array.
Therefore 0000 is a valid code.
2.Sales per salesman by model. If this option is selected, again, similar transaction code (as described in
1)is entered first. (The verification MUST be done for all options)
Suppose the code 0111 was entered. This is a valid code. This means salesman 01, 11th model. Read
the (01,11) location of the 2-D array and display the following information
Sales Representative Code : 01
Automobile Model : Mirage
Total Sold By This Representative : 4
3. All Sales Per Salesman. This is similar to option 2 except for that all models sold by that representative
is displayed.
As an example , say the code 0809 was entered. This is also a valid code. The following information is
displayed on the screen.
Sales Representative Code : 08
Automobile Model Number Sold
Camry 0
Corolla 2
Tercel 6
Mazda3 1
Marda6 0
Protégé 2
Altima 2
Maxima 1
Sentra 1
Diamante 2
Colt 1
Mirage 5
Legacy 4
Stylus 3
Impulse 0
Total 30
==========
4.Total Sales for the company : A monthly sales report must be produced in the following form:
MODEL
Salesman Ca Cr Te M3 M6 Pro Alt Max Sen Dia Col Mir Leg Sty Imp Total
0 0 0 2 0 5 6 3 1 3 4 3 4 3 1 0 35
1 5 1 9 0 0 2 3 2 2 3 1 3 6 2 1 40
2 0 0 0 1 0 0 0 3 1 6 2 1 7 3 2 26
3 1 1 1 0 2 2 2 5 2 7 4 2 8 2 1 40
4 5 3 2 0 0 0 5 2 1 2 6 6 6 1 4 43
5 4 2 1 0 1 1 0 4 4 1 5 5 1 2 1 32
6 3 2 5 0 1 2 0 1 3 5 4 3 2 1 2 34
7 3 0 7 1 3 5 1 0 6 8 2 2 3 2 1 44
8 0 2 6 1 0 2 2 1 1 2 1 5 4 3 0 30
9 4 0 2 3 2 1 3 2 3 1 5 4 0 1 0 33
-------------------
-----
-----
-----
-----
-----
-----
----------
----
------
-----
------
25
11 35 6 13 21 19 21 27 39 33 35 40 18 12 357
In the actual print out, all the above abbreviated names should be printed as full names as shown in
the type declaration above.
You can hardcode the initial 2-D array to the following. You can hardcode the initial 2-D array to the following.
0 1 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 1 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 1 0 0 1 0 0 0 0 0
Figure 2 –
Initial 2-D Array
(Note : 0000 is a valid code)
In your program code, you MUST make sure (verification & validation is required) that the correct code is
used to access the table. For example, the user enters the code 1512. This is an invalid code. Your
program must be intelligent enough to detect this and display a proper error message.
For testing purposes you may build your own set of data. You must test your application using the given
scenario.
All output files must have appropriate headings and self documenting information. Identifiers must be
meaningful. The program should be laid out neatly. Block structure should be used to localize
declarations (Avoid Global Variables as much as possible). Whenever possible a piece of information
should be written once; thus numbers and constant declarations should be used rather than explicit
literals. Make all subroutines shorter as possible.
/**
C # program that demonstrates the sales by models
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//create a console project with name salespr
namespace salespr
{
class Program
{
//set number of sales
man and item models
private const int
PERSONS = 10;
private const int ITEMS
= 15;
//array of model
names
static string[]
modelNames ={"Camry", "Corolla", "Tercel", "Protege", "Mazda3",
"Mazda6",
"Altima", "Maxima",
"Sentra", "Diamante", "colt", "Mirage",
"Legacy", "Stylus",
"Impulse"};
static void
Main(string[] args)
{
//sales array
int[,] sales ={{0, 0, 2, 0, 5, 6, 3, 1, 3, 4, 3, 3, 1, 0, 2
},
{5, 1, 9, 0, 0, 2, 3, 2, 2, 3, 1, 4, 6, 2, 1 },
{0, 0, 0, 1, 0, 0, 0, 3, 1, 6, 2, 1, 7, 3, 2},
{1, 1, 1, 0, 2, 2, 2, 5, 2, 7, 4, 2, 8, 2, 1 },
{5, 3, 2, 0,0, 0, 5,2, 1, 2, 6, 6, 6, 1, 4},
{4, 2, 1, 0, 1, 1, 0, 4, 4, 1, 5, 5, 1, 2, 1 },
{3, 2, 5, 0, 1, 2, 0, 1, 3, 5, 4, 3, 2, 1, 2 },
{3, 0, 7, 1, 3, 5, 1, 0, 6, 8, 2, 2, 3, 2, 1 },
{0, 2, 6, 1, 0, 2, 2, 1, 1, 2, 1, 5, 4, 3, 0 },
{4, 0, 2, 3, 2, 1, 3, 2, 3, 1, 5, 4, 0, 1, 0 }
};
bool repeat = true;
int choice;
while (repeat)
{
choice = menu();
switch (choice)
{
case 1:
addNewSale(sales);
break;
case 2:
salerPerSalesman(sales);
break;
case 3:
allSalesPerSalesman(sales);
break;
case 4:
totalSales(sales);
break;
case 5:
Environment.Exit(0);
break;
}
}
}
//print total sales
of sales man
public static void
totalSales(int[,] sales)
{
int totalSum = 0;
int rowSum = 0;
int colSum = 0;
for (int salesman = 0; salesman < PERSONS; salesman++)
{
for (int item = 0; item < ITEMS; item++)
{
rowSum += sales[salesman, item];
Console.Write("{0,-3}", sales[salesman, item]);
}
Console.WriteLine("{0,-3}", rowSum);
rowSum = 0;
}
for (int item = 0; item < ITEMS;
item++)
{
for (int salesman = 0; salesman < PERSONS;
salesman++)
{
colSum +=
sales[salesman,item];
}
totalSum += colSum;
Console.Write("{0,-3}", colSum);
colSum = 0;
}
Console.WriteLine("{0}",totalSum);
}
//print all sales of the
sales to console
public static void
allSalesPerSalesman(int[,] sales)
{
Console.WriteLine("Enter Transaction Code : ");
string code = Console.ReadLine();
int salesManCode = Convert.ToInt32(code.Substring(0, 2));
int modelCode = Convert.ToInt32(code.Substring(2));
if (isValid(salesManCode, modelCode))
Console.WriteLine("Invalid code");
else
{
for (int i = 0; i < ITEMS; i++)
{
Console.WriteLine("{0} : {1}", modelNames[i], sales[salesManCode,
i]);
}
}
}
//method that add a
sale to the sales man
public static void
addNewSale(int[,] sales)
{
Console.WriteLine("Enter Transaction Code : ");
string code = Console.ReadLine();
int salesManCode = Convert.ToInt32(code.Substring(0, 2));
int modelCode = Convert.ToInt32(code.Substring(2));
if (isValid(salesManCode, modelCode))
Console.WriteLine("Invalid code");
else
{
sales[salesManCode, modelCode] = sales[salesManCode, modelCode] +
1;
}
}
//print the sales per
sales man
public static void
salerPerSalesman(int[,] sales)
{
Console.WriteLine("Enter Transaction Code : ");
string code = Console.ReadLine();
int salesManCode = Convert.ToInt32(code.Substring(0, 2));
int modelCode = Convert.ToInt32(code.Substring(2));
if (isValid(salesManCode, modelCode))
Console.WriteLine("Invalid code");
else
{
Console.WriteLine("Sales Representative Code : {0}",
salesManCode);
Console.WriteLine("Automobile Model : {0}",
modelNames[modelCode]);
Console.WriteLine("Total Sold By This Representative : {0}",
sales[salesManCode, modelCode]);
}
}
//Check for validity
of code
public static bool
isValid(int salesManCode, int modelCode)
{
return (salesManCode < 0 || salesManCode > 10) || (modelCode
< 0 || modelCode > 15);
}
//Menu method
public static int
menu()
{
Console.WriteLine("\n\n1.Add a new sale ");
Console.WriteLine("2.Sales Per Salesman by model");
Console.WriteLine("3.All Sales Per Salesman ");
Console.WriteLine("4.All Sales For The Company ");
Console.WriteLine("5.Exit ");
Console.WriteLine("Enter your choice");
int choice = Convert.ToInt32(Console.ReadLine());
return choice;
}
}
}
Sample Output:
1.Add a new sale
2.Sales Per Salesman by model
3.All Sales Per Salesman
4.All Sales For The Company
5.Exit
Enter your choice
1
Enter Transaction Code :
0000
1.Add a new sale
2.Sales Per Salesman by model
3.All Sales Per Salesman
4.All Sales For The Company
5.Exit
Enter your choice
4
1 0 2 0 5 6 3 1 3 4 3 3 1 0 2 34
5 1 9 0 0 2 3 2 2 3 1 4 6 2 1 41
0 0 0 1 0 0 0 3 1 6 2 1 7 3 2 26
1 1 1 0 2 2 2 5 2 7 4 2 8 2 1 40
5 3 2 0 0 0 5 2 1 2 6 6 6 1 4 43
4 2 1 0 1 1 0 4 4 1 5 5 1 2 1 32
3 2 5 0 1 2 0 1 3 5 4 3 2 1 2 34
3 0 7 1 3 5 1 0 6 8 2 2 3 2 1 44
0 2 6 1 0 2 2 1 1 2 1 5 4 3 0 30
4 0 2 3 2 1 3 2 3 1 5 4 0 1 0 31
26 11 35 6 14 21 19 21 26 39 33 35 38 17 14 355
1.Add a new sale
2.Sales Per Salesman by model
3.All Sales Per Salesman
4.All Sales For The Company
5.Exit
Enter your choice
1
Enter Transaction Code :
0001
1.Add a new sale
2.Sales Per Salesman by model
3.All Sales Per Salesman
4.All Sales For The Company
5.Exit
Enter your choice
4
1 1 2 0 5 6 3 1 3 4 3 3 1 0 2 35
5 1 9 0 0 2 3 2 2 3 1 4 6 2 1 41
0 0 0 1 0 0 0 3 1 6 2 1 7 3 2 26
1 1 1 0 2 2 2 5 2 7 4 2 8 2 1 40
5 3 2 0 0 0 5 2 1 2 6 6 6 1 4 43
4 2 1 0 1 1 0 4 4 1 5 5 1 2 1 32
3 2 5 0 1 2 0 1 3 5 4 3 2 1 2 34
3 0 7 1 3 5 1 0 6 8 2 2 3 2 1 44
0 2 6 1 0 2 2 1 1 2 1 5 4 3 0 30
4 0 2 3 2 1 3 2 3 1 5 4 0 1 0 31
26 12 35 6 14 21 19 21 26 39 33 35 38 17 14 356
1.Add a new sale
2.Sales Per Salesman by model
3.All Sales Per Salesman
4.All Sales For The Company
5.Exit
Enter your choice
2
Enter Transaction Code :
0000
Sales Representative Code : 0
Automobile Model : Camry
Total Sold By This Representative : 1
1.Add a new sale
2.Sales Per Salesman by model
3.All Sales Per Salesman
4.All Sales For The Company
5.Exit
Enter your choice
3
Enter Transaction Code :
0000
Camry : 1
Corolla : 1
Tercel : 2
Protege : 0
Mazda3 : 5
Mazda6 : 6
Altima : 3
Maxima : 1
Sentra : 3
Diamante : 4
colt : 3
Mirage : 3
Legacy : 1
Stylus : 0
Impulse : 2
1.Add a new sale
2.Sales Per Salesman by model
3.All Sales Per Salesman
4.All Sales For The Company
5.Exit
Enter your choice
5
Objective: Learn basic C# Programming Language A certain automobile dealership sells fifteen different models of automobiles...
PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP AND FORMAT: #include <iostream> using namespace std; int main() { //variables here do { // program here }while (true); } Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Write an interactive C++.program to have a user input the length of three sides of a triangle. Allow the user to enter the sides...
PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE 11. Initialize a integers in the two-dimensional array testArray to the values 1 through 9 using 1 or more while loops so that the array could be visualized as: 1 2 3 LA 5 6 7 8 9...
Please answer using C ++ programming language ONLY! We have only used <stdio.h> if that helps. This is a basic course and the furthest we have gone is BASIC arrays. Write the code for the following problems using arrays. Write what would go in the “int main()” part of the program. For these problems, the entire program and program output is not needed. Just include what goes in the int main() part of the program. 1. Declare an integer array...
Java - Car Dealership Hey, so i am having a little trouble with my code, so in my dealer class each of the setName for the salesman have errors and im not sure why. Any and all help is greatly appreciated. package app5; import java.util.Scanner; class Salesman { private int ID; private String name; private double commRate; private double totalComm; private int numberOfSales; } class Car { static int count = 0; public String year; public String model; public String...
Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array. The program...
Suppose we have the following annual sales data for an automobile dealership: Year Sales Trend 2009 121 1 2010 187 2 2011 165 3 2012 134 4 2013 155 5 2014 167 6 2015 200 7 2016 206 8 2017 221 9 2018 231 10 We want to forecast sales for 2019 and 2020 using either a simple trend model or a quadratic trend model. Use a within sample forecasting technique...
c++ problem You are asked to implement a car ordering system for Bobcats Auto Dealership. This dealership is brand new and only sells one brand of cars with three different models. However, a buyer can add options if they choose. Write a C++ program that allows the user to order a single car with different options. All the options available will be stored in a file called "options.txt" along with their cost. You may assume that the file will not...
Programming Language: C++ Develop a seat reservation system for your airline. Consider the following airline seating pattern: A 1 2 3 4 5 6 7 8 9 …… 100 B 1 2 3 4 5 6 7 8 9 …… 100 AISLE C 1 2 3 4 5 6 7 8 9 …… 100 D 1 2 3 4 5 6 7 8 9 …… 100 Either use 2D STL array (array that contains array) or 4 single dimensional STL arrays of size 100. Write a program to display a menu to the user with the options to reserve a seat of choice, reserve a window seat, reserve an aile seat, reserve a seat (any available), withdraw reservation, update reservation (change seat) and display...
Programming Language: Java Please write a program that uses a recursive algorithm to compute the determinant of a matrix. It should read the order of the matrix, read the matrix, print it out, compute, and print the determinant. Your program should be able to evaluate multiple matrices on a single execution. For class purposes, your program should handle matrices up to and including those of order 6. You are required to use an array for this problem. Your solution must...
Language is C programming Student ID should be 8 numbers long. create a program to read your student ID number and store it in an array. Input can not be hard wired, I have to be able to input my number Then change the first number to a letter. If the same number repeats in other parts of your student ID, you must change that number to a letter as well. print original array and modified array as your output....