You will be creating TWO console applications from pages 223 and 224 in your book.

6.17 -- name it "Ch6-17" (Visual C# 2012 How To Program (Fifth Edition – Fourth Edition Acceptable) )
Create a class called ShoppingCart with a single method called FillCart that that does the requested tasks. Do not put anything in your main method except for the creation of the ShoppingCart class and a single call to FillCart.
Hint: They are asking for a loop that asks for two separate values (two ReadLines). The loop should terminate if the user enters a specific value for one of the items. Just have the loop terminate (i.e., break) when the user enters a 0 for a product id. Each time through the loop, you should use a switch statement to check the product id and add the appropriate product price (* quantity) to the running total. After the loop is terminated, you are to print the total. NOTE: If the user enters a product id that doesn't exist, you should also let them know this and (obviously) not add any amount to a running total.

6.21 -- name it "Ch6-21"
Do this as described in the book. BUT,
a) this should be in a class called Pythagoras and a method called Triples
b) the method should take a single parameter that determines the largest side to test (i.e., the maximum a/b/c value---in other words, don't just assume that you should stop at 500)
c) the method should keep track two running totals: the number of triples found and the total number of combinations attempted...increment these at the appropriate place in your code to give you the correct counts
d) at the end of the loop, display these totals with an appropriate label (e.g., "Total Found: 123")
e) your main method should ask the user for the largest side, create an instance of Pythagoras, and call Triples with the value provided by the user
Hint: As the book says, this is a loop nested in a loop nested in a loop testing ALL values of a, b, and c (i.e., a^2+b^2=c^2a2+b2=c2) between 1 and the max value. Print out the three sides in the form:
a = NUM, b = NUM, c = NUM
for all combinations that work. ONLY for the combinations that work. And yes, this is "brute force" at its most profound.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ch6_17
    class ShoppingCart
       public void FillCart()
            int productId = 5;
            int quantity;            
            double total = 0.0;
            Console.WriteLine(" product1: $2.98\n product 2: $4.50\n product 3: $9.98\n");

            while (productId != 0)
                Console.Write(" product id: ");
                productId = Convert.ToInt32(Console.ReadLine());    ...

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats