Created
November 11, 2011 01:22
-
-
Save jpetto/1356847 to your computer and use it in GitHub Desktop.
Intro to Programming - Quiz #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace ConsoleQuiz3 { | |
class Program { | |
static void Main(string[] args) { | |
List<Pasta> pastas = Pasta.ServeDinner(); | |
// calculate and display the total calories of all the pastas (1 point) | |
// calculate and display the average calories per dish (1 point) | |
// calculate and display the total number of pastas of each type of sauce - meat, pesto, and cream (3 points) | |
// extra credit - calculate and display the percentage of diners that ordered the meat sauce (1 point) | |
Console.ReadKey(true); | |
} | |
} | |
class Pasta { | |
public string Sauce; | |
public int Calories; | |
public Pasta(string sauce, int calories) { | |
this.Sauce = sauce; | |
this.Calories = calories; | |
} | |
public static List<Pasta> ServeDinner() { | |
List<Pasta> pastas = new List<Pasta>(); | |
pastas.Add(new Pasta("Meat", 970)); | |
pastas.Add(new Pasta("Pesto", 1030)); | |
pastas.Add(new Pasta("Cream", 930)); | |
pastas.Add(new Pasta("Pesto", 660)); | |
pastas.Add(new Pasta("Cream", 790)); | |
pastas.Add(new Pasta("Meat", 660)); | |
pastas.Add(new Pasta("Cream", 930)); | |
pastas.Add(new Pasta("Pesto", 800)); | |
pastas.Add(new Pasta("Pesto", 800)); | |
pastas.Add(new Pasta("Meat", 970)); | |
pastas.Add(new Pasta("Meat", 970)); | |
pastas.Add(new Pasta("Meat", 970)); | |
pastas.Add(new Pasta("Pesto", 1030)); | |
pastas.Add(new Pasta("Cream", 930)); | |
pastas.Add(new Pasta("Pesto", 660)); | |
pastas.Add(new Pasta("Meat", 970)); | |
pastas.Add(new Pasta("Pesto", 1030)); | |
pastas.Add(new Pasta("Cream", 930)); | |
pastas.Add(new Pasta("Pesto", 660)); | |
return pastas; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment