Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prompt Add one additional method that will use calculated values for items and convert Total Price per each of selected units from US Dollars into

Prompt

Add one additional method that will use calculated values for items and convert Total Price per each of selected units from US Dollars into EU currency. Use conversion factor 1 USD = 0.83 EU

For every place in the program that displays an amount in U.S. dollars, modify the code to use your new method above so the exact same output showing U.S. dollars is immediately followed by the Euro equivalent amount. Be sure to use labeling when you are printing to make it clear that any amount you are printing in euros is Euros. For example: Unit price: $2.00 Unit price in euros: $2.41 Total cost: $6 Total cost in euros: $7.73

======== start Main Application code =======

/* ReceiptApp.cs * This class tests the Receipt class * by constructing objects, testing properties * and methods. */

using System; using static System.Console;

namespace ReceiptApp { class ReceiptApp { static void Main(string[] args) { Receipt firstReceiptObject = new Receipt(); firstReceiptObject.ReceiptNumber = AskForStringInput("Receipt Number"); firstReceiptObject.CustomerNumber = AskForStringInput("Customer Number"); firstReceiptObject.CustomerFirstName = AskForStringInput("Customer First Name"); firstReceiptObject.CustomerLastName = AskForStringInput("Customer Last Name"); firstReceiptObject.CustomerPhone = AskForStringInput("Customer Phone"); firstReceiptObject.CustomerAddress = AskForStringInput("Customer Address"); firstReceiptObject.ItemNumber = AskForStringInput("Item Number Purchased"); firstReceiptObject.ItemDesc = AskForStringInput ("Description of the Part"); firstReceiptObject.UnitPrice = AskForUnitPrice(); firstReceiptObject.QtyPurchased = AskForQtyPurchased(); Clear(); WriteLine("\tFirst Test"); WriteLine(firstReceiptObject.ToString());

Receipt secondReceiptObject = new Receipt("XYC-2345"); secondReceiptObject.DateOfPurchase = "09/25/2013"; secondReceiptObject.CustomerFirstName = "David"; secondReceiptObject.CustomerLastName = "Zeller"; secondReceiptObject.CustomerNumber = "001237"; secondReceiptObject.CustomerAddress = "14 Parks Blvd"; secondReceiptObject.CustomerPhone = "762-123-4412"; secondReceiptObject.ItemNumber = "4XZ23-7"; secondReceiptObject.ItemDesc = "Wiper blade"; secondReceiptObject.UnitPrice = 9.50; secondReceiptObject.QtyPurchased = 2; WriteLine(" \tSecond Test"); WriteLine("Receipt Number: " + secondReceiptObject.ReceiptNumber + " - Date: " + secondReceiptObject.DateOfPurchase); WriteLine("Description of Part: " + secondReceiptObject.ItemDesc); WriteLine("Item Number: " + secondReceiptObject.ItemNumber + " Quantity Purchased: " + secondReceiptObject.QtyPurchased + " Total Cost: {0}", secondReceiptObject.CalculateTotalCost( ).ToString("c"));

Receipt thirdReceiptObject = new Receipt("TY-5432", "0004567"); thirdReceiptObject.CustomerFirstName = "Anna"; thirdReceiptObject.CustomerLastName = "Leigh"; thirdReceiptObject.UnitPrice = 7.22; thirdReceiptObject.QtyPurchased = 3; WriteLine(" \tThird Test"); WriteLine(thirdReceiptObject);

Receipt lastReceiptObject = new Receipt("XYC-2349", "11/05/2013", "001238", "Elizabeth", "Smith", "1247 Fenelon Falls Rd", "343-12-9876", "XQ-1267", "Brake Fluid", 14.78, 5); WriteLine(" \tLast Test"); WriteLine("Item Description: " + lastReceiptObject.ItemDesc + " Item Number: " + lastReceiptObject.ItemNumber + " Qty Purchased: " + lastReceiptObject.QtyPurchased + " Unit Price: " + lastReceiptObject.UnitPrice.ToString("f2") + " Total Cost: " + lastReceiptObject.CalculateTotalCost().ToString("C"));

ReadKey(); }

static double AskForUnitPrice() { string inValue; double theUnitPrice; Write("Enter Unit Price: "); inValue = ReadLine(); theUnitPrice = double.Parse(inValue); return theUnitPrice; }

static string AskForStringInput(string whatData) { string inValue; Write("Please enter {0}: ", whatData); inValue = ReadLine(); return inValue; }

static int AskForQtyPurchased( ) { string inValue; Write("Enter Quantity Purchased: "); inValue = ReadLine(); return (int.Parse(inValue)); } } }

======== end Main Application code ========

======== start Class code Also available in the REceiptApplication zipped package=======

/* Receipt.cs * This class includes data member that could be used by an automobile * parts store. Items included as data members are customer name, address, * phone, receipt number, item number purchased, description, * unit price and quantity purchased. */

using System;

namespace ReceiptApp { class Receipt { private string receiptNumber; private string dateOfPurchase; private string customerNumber; private string customerFirstName; private string customerLastName; private string customerAddress; private string customerPhone; private string itemNumber; private string itemDesc; private double unitPrice; private int qtyPurchased;

public Receipt() { }

public Receipt (string rNum) { receiptNumber = rNum; }

public Receipt(string rNum, string cNum) { receiptNumber = rNum; customerNumber = cNum; }

public Receipt(string rNum, string cNum, string cFName, string cLName, string cAddress, string cPhone) { receiptNumber = rNum; customerNumber = cNum; customerLastName = cLName; customerFirstName = cFName; customerAddress = cAddress; customerPhone = cPhone; } public Receipt (string rNum, string iNum, string iDesc, double uPrice, int qty) { receiptNumber = rNum; itemNumber = iNum; itemDesc = iDesc; unitPrice = uPrice; qtyPurchased = qty; }

public Receipt(string rNum, string cNum, string iNum, string iDesc, double uPrice, int qty) { receiptNumber = rNum; customerNumber = cNum; itemNumber = iNum; itemDesc = iDesc; unitPrice = uPrice; qtyPurchased = qty; }

public Receipt(string rNum, string purchaseDate, string cNum, string cFName, string cLName, string cAddress, string cPhone, string iNum, string iDesc, double uPrice, int qty) { receiptNumber = rNum; dateOfPurchase = purchaseDate; customerNumber = cNum; customerFirstName = cFName; customerLastName = cLName; customerAddress = cAddress; customerPhone = cPhone; itemNumber = iNum; itemDesc = iDesc; unitPrice = uPrice; qtyPurchased = qty; }

public string ReceiptNumber { get { return receiptNumber; } set { receiptNumber = value; } }

public string DateOfPurchase { get { return dateOfPurchase; } set { dateOfPurchase = value; } }

public string CustomerNumber { get { return customerNumber; } set { customerNumber = value; } }

public string CustomerFirstName { get { return customerFirstName; } set { customerFirstName = value; } }

public string CustomerLastName { get { return customerLastName; } set { customerLastName = value; } } public string CustomerAddress { get { return customerAddress; } set { customerAddress = value; } }

public string CustomerPhone { get { return customerPhone; } set { customerPhone = value; } }

public string ItemNumber { get { return itemNumber; } set { itemNumber = value; } }

public string ItemDesc { get { return itemDesc; } set { itemDesc = value; }

}

public double UnitPrice { get { return unitPrice; } set { unitPrice = value; } }

public int QtyPurchased { get { return qtyPurchased; } set { qtyPurchased = value; } }

public double CalculateTotalCost() { return unitPrice * qtyPurchased; }

public override string ToString() { return "Customer: " + customerFirstName + " " + customerLastName + " Phone: " + customerPhone + " Total Purchases: " + CalculateTotalCost().ToString("C");

} } }

======== end Class code ========

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions