Click here to Skip to main content
15,890,690 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to serialize this? Pin
Sphinxniuie12-Aug-15 21:48
Sphinxniuie12-Aug-15 21:48 
GeneralRe: How to serialize this? Pin
Richard MacCutchan12-Aug-15 21:52
mveRichard MacCutchan12-Aug-15 21:52 
QuestionWPF TabControl content memory leak Pin
theonlyavenger12-Aug-15 11:17
theonlyavenger12-Aug-15 11:17 
AnswerRe: WPF TabControl content memory leak Pin
Pete O'Hanlon12-Aug-15 11:24
mvePete O'Hanlon12-Aug-15 11:24 
GeneralRe: WPF TabControl content memory leak Pin
theonlyavenger13-Aug-15 9:41
theonlyavenger13-Aug-15 9:41 
Questionprice calculator Pin
Member 1190452712-Aug-15 5:23
Member 1190452712-Aug-15 5:23 
AnswerRe: price calculator Pin
Eddy Vluggen12-Aug-15 5:31
professionalEddy Vluggen12-Aug-15 5:31 
GeneralRe: price calculator Pin
Member 1190452712-Aug-15 5:45
Member 1190452712-Aug-15 5:45 
The program presently performs the number reading for the item price inside the main loop. Improve the structure of the program by writing the C# code for a method called readInteger which has the following signature:
int readInteger ( string prompt )
Modify the program to use this method.

class PriceCalc { static void Main(string[] args)
{
float costPrice = 0.0f;
float profit;
float tax; float totalCost = 0.0f;
float totalProfit = 0.0f;
float totalTax = 0.0f;
bool finished = false;
float salePrice;

string priceString;
string nameString; float taxRate = 0.2f;
while (!finished) {
Console.Write("Enter the name of the product : ");
nameString = Console.ReadLine(); Console.WriteLine("Product is " + nameString);
if (nameString.Length != 0) {
finished = true;
} else
{ bool dataOK = false;
while (!dataOK)
{
Console.Write("Enter price of the product : ");
priceString = Console.ReadLine(); try {
costPrice = float.ParsepriceString); dataOK =true; catch
{
Console.WriteLine("That is not a valid number");
Console.WriteLine("Enter a number, e.g. 15.5");
}
}
if (costPrice < 20.0f) {
profit = costPrice * 0.2f;
} else { if (costPrice < 40.0f) {
profit = costPrice * 0.15f; // } else

{
profit = costPrice * 0.1f;

}
}
tax = (costPrice + profit) * taxRate;
totalTax = totalTax + tax; totalCost = totalCost + costPrice; totalProfit = totalProfit + profit;
salePrice = costPrice + profit + tax;
GeneralRe: price calculator [warning, long post] Pin
Eddy Vluggen12-Aug-15 6:45
professionalEddy Vluggen12-Aug-15 6:45 
GeneralRe: price calculator [warning, long post] Pin
Member 1190452712-Aug-15 6:59
Member 1190452712-Aug-15 6:59 
GeneralRe: price calculator [warning, long post] Pin
Eddy Vluggen12-Aug-15 7:11
professionalEddy Vluggen12-Aug-15 7:11 
GeneralRe: price calculator [warning, long post] Pin
Matt T Heffron12-Aug-15 14:34
professionalMatt T Heffron12-Aug-15 14:34 
GeneralRe: price calculator [warning, long post] Pin
Eddy Vluggen12-Aug-15 20:05
professionalEddy Vluggen12-Aug-15 20:05 
GeneralRe: price calculator [warning, long post] Pin
Eddy Vluggen12-Aug-15 20:05
professionalEddy Vluggen12-Aug-15 20:05 
SuggestionRe: price calculator [warning, long post] Pin
Matt T Heffron13-Aug-15 6:24
professionalMatt T Heffron13-Aug-15 6:24 
GeneralRe: price calculator [warning, long post] Pin
Eddy Vluggen13-Aug-15 9:21
professionalEddy Vluggen13-Aug-15 9:21 
GeneralRe: price calculator [warning, long post] Pin
Matt T Heffron13-Aug-15 10:39
professionalMatt T Heffron13-Aug-15 10:39 
GeneralRe: price calculator [warning, long post] Pin
Eddy Vluggen14-Aug-15 3:28
professionalEddy Vluggen14-Aug-15 3:28 
GeneralRe: price calculator [warning, long post] Pin
Matt T Heffron14-Aug-15 7:08
professionalMatt T Heffron14-Aug-15 7:08 
GeneralRe: price calculator [warning, long post] Pin
Mycroft Holmes12-Aug-15 14:58
professionalMycroft Holmes12-Aug-15 14:58 
GeneralRe: price calculator [warning, long post] Pin
Eddy Vluggen12-Aug-15 20:07
professionalEddy Vluggen12-Aug-15 20:07 
Questionwhat can i use to create an installer Pin
jamesmc153511-Aug-15 22:36
jamesmc153511-Aug-15 22:36 
AnswerRe: what can i use to create an installer Pin
Richard MacCutchan12-Aug-15 2:00
mveRichard MacCutchan12-Aug-15 2:00 
AnswerRe: what can i use to create an installer Pin
dhaval.panchal512-Aug-15 3:02
dhaval.panchal512-Aug-15 3:02 
GeneralRe: what can i use to create an installer Pin
jamesmc153512-Aug-15 3:04
jamesmc153512-Aug-15 3:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.