Question
My code is suppose to display a 2d table and menu about car salemans and the number of cars they sale, as well as analytics
My code is suppose to display a 2d table and menu about car salemans and the number of cars they sale, as well as analytics about sales. My computer is having issues and wont allow me to get output for my code which is listed below. What would be the output if:
1. Add a new sale - code 0113 (select item 1 in your menu)
2. Add a new sale - code 0000 same
3. Add a new sale - code 0606 same
4. Add a new sale - code 0314 same
5. Show sales per salesman by model - code 0004 (select item 2 in your menu)
6. Show sales per salesman by model - code 0000 same
7. Show sales per salesman by model - code 0914 same
8. Show all sales for the salesman 06 (select item 3 in your menu)
9. Show all sales for the salesman 00 same
10. Show all sales for the company (select item 4 in your menu)
I need the snapshots of each, if you dont mind sharing in google docs.
CODE I CAME UP WITH:
using System.IO; using System;
class Program { static int row = 10; //number of salesperson static int col = 15; //number of car model static string[] model = new string[] {"Porsche","Acura","Escalade","Lexus","Audi","Bentley","Altima","Jaguar","Volvo","Infiniti","BMW","Rolls-Royce","Land Rover","Westfield","Caparo" }; static void add(int[,]arr,int code1,int sale) { int num=code1,temp,factor=1,i=0; int [] code = new int[4]; temp=num; //breaking code while(temp!=0) { temp=temp/10; factor = factor*10; } while(factor>1) { factor = factor/10; code[i]=num/factor; num = num % factor; i++; } int salesman=code[0]; Console.WriteLine("Sales man is: "+salesman); if(salesman>10) Console.WriteLine("ERROR: invalid salesman code :"+salesman+"!!!"); else { int automobile=(code[1]*10)+code[2]; Console.WriteLine("automobile is: "+automobile); if(automobile>15) Console.WriteLine("ERROR: invalid automobile code :"+automobile+"!!!"); else { arr[salesman,automobile]=arr[salesman,automobile]+sale; Console.WriteLine("Sale is increamented by "+sale); } } Console.WriteLine("Updated Sales table is: "); for (i = 0; i < row; i++) { for (int j = 0; j < col; j++) Console.Write(arr[i,j]+ " "); Console.Write(" "); } } static void per_salesman(int [,]arr,int code1) { int num=code1,temp,factor=1,i=0; int [] code = new int[4]; temp=num; //breaking code while(temp!=0) { temp=temp/10; factor = factor*10; } while(factor>1) { factor = factor/10; code[i]=num/factor; num = num % factor; i++; } int salesman=code[0]; Console.WriteLine("Sales Representative Code : "+salesman); if(salesman>10) Console.WriteLine("ERROR: invalid salesman code :"+salesman+"!!!"); else { int automobile=(code[1]*10)+code[2]; //Console.WriteLine("automobile is: "+automobile); if(automobile>15) Console.WriteLine("ERROR: invalid automobile code :"+automobile+"!!!"); else { Console.WriteLine("Automobile Model : "+model[automobile]); Console.WriteLine("Total Sold By This Representative : "+arr[salesman,automobile]); } } } static void all_per_salesman(int [,]arr,int code1) { int num=code1,temp,factor=1,i=0; int [] code = new int[4]; temp=num; //breaking code while(temp!=0) { temp=temp/10; factor = factor*10; } while(factor>1) { factor = factor/10; code[i]=num/factor; // code is now strored in code[] num = num % factor; i++; } int salesman=code[0]; Console.WriteLine("Sales Representative Code : "+salesman); if(salesman>10) Console.WriteLine("ERROR: invalid salesman code :"+salesman+"!!!"); else { int automobile=(code[1]*10)+code[2]; if(automobile>15) Console.WriteLine("ERROR: invalid automobile code :"+automobile+"!!!"); else { Console.WriteLine("Automobile Model \t Model Sold"); Console.WriteLine("-----------------\t -----------"); for(int k=0;k
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started