|
I have this assignment with arrays and I'm totally lost. I'm ready to drop out of the class because it is too hard for me. I just want to finish the class and not fail.
Develop a C# console application that implements two parallel arrays in Main, one to hold double values called item_price and the other to hold strings called item_name. Each array will hold 5 values. Use an initializer to fill the item_price array with the values 15.50, 50.99, 25.00, 115.49, 75.25. Use an initializer to fill the item_name array with the values "Widget", "Thingy", "Ratchet", "Clanger", "Fracker". This application will use a method to change the corresponding prices for items based on a price point and a multiplier which will require double value types. The inputs for the price and multiplier are input from the console.
Create two static methods, one called changePrices and one called printit. When the changePrices method is called from Main you should pass the item_price array by reference, the price point and price difference values input from the console to it. The changePrices method should loop through the item price array and check the price point to determine the increase in price for each price array element.
|
|
|
|
|
Member 10063234 wrote: the price point and price difference values input from the console to it. The changePrices method should loop through the item price array and check the price point to determine the increase in price for each price array element. What does that even mean?
|
|
|
|
|
That is what I said. This is the whole assignment and I'm totally lost. I've read the chapter over and over again.
Develop a C# console application that implements two parallel arrays in Main, one to hold double values called item_price and the other to hold strings called item_name. Each array will hold 5 values. Use an initializer to fill the item_price array with the values 15.50, 50.99, 25.00, 115.49, 75.25. Use an initializer to fill the item_name array with the values "Widget", "Thingy", "Ratchet", "Clanger", "Fracker". This application will use a method to change the corresponding prices for items based on a price point and a multiplier which will require double value types. The inputs for the price and multiplier are input from the console.
Create two static methods, one called changePrices and one called printit. When the changePrices method is called from Main you should pass the item_price array by reference, the price point and price difference values input from the console to it. The changePrices method should loop through the item price array and check the price point to determine the increase in price for each price array element. The basic computation is:
if the current price is less than the price point then set the price equal to the current price plus the current price times the price multiplier
In the printit method print the item name and the corresponding item price to the console as shown in the output example below.
The price for item Widget is $15.50
The price for item Thingy is $50.99
The price for item Ratchet is $25.00
The price for item Clanger is $115.49
The price for item Fracker is $75.25
Enter the price cutoff point (eg $15.00) $60.00
Enter the percentage price change (eg 0.25) 0.15
The price for item Widget is $17.83
The price for item Thingy is $58.64
The price for item Ratchet is $28.75
The price for item Clanger is $115.49
The price for item Fracker is $75.25
Press any key to continue . . .
|
|
|
|
|
Ok, now it makes sense. What do you have so far?
|
|
|
|
|
using System;
public class InitArray
{
public InitArray()
{
string[] name = {"Widget", "Thingy", "Ratchet", "Clanger", "Fracker"};
double[] price = {15.50, 50.99, 25.00, 115.49, 75.25};
|
|
|
|
|
Hi Alll
Please Anybody have code or knowledge about this question please send me give solution.
thanking you for supporting me.
Pankaj Tak
|
|
|
|
|
Not enough information. What printer and attached to what machine? Are you talking about a network printer the IIS server can see? Are you talKing about pages per job or total pages that have gone through the queue? Or are you talking about the must of pages the printer has put through during it's lifetime?
|
|
|
|
|
Sir Thanking you for reply me.
I am talking about the printer attached with computer.
when printer print the pages per day through our attached printer.i want to count the how many pages print on that day.
e.g if 350 pages print on that day.I want to count just numbers of pages print on day using asp.net with C#. so sir please guide me how to solve this problem.please provide me Code for that program.
I am waiting for your positive Reply sir.
Thanking You So much for helping me.
|
|
|
|
|
Thanks for reply me.
I am talking about computer attach to printer then we print pages from particular printer in a day. I just want that everyday printer that attach to the system(windows 7) count the numbers of pages that day only.I want everyday how many pages print from Printer thats only Sir.
Using asp.net With C#
Thanking you
I waiting your reply sir
|
|
|
|
|
ASP.NET code runs entirely on a web server, not the client machine. You cannot do what you want in a web application. Well, not unless the server is hosting all of the printers you want stats on.
|
|
|
|
|
its not possible in asp.net ?
|
|
|
|
|
What did I just say??
If you're talking about the printers attached to the clients machine, NO IT'S NOT POSSIBLE IN ASP.NET.
ASP.NET code runs ENTIRELY on the server, not the client. ASP.NET code has no way to get at the devices attached to a client computer. It can ONLY use the stuff attached to the server.
|
|
|
|
|
its is possible only server not client machine?
How can I made for server machine using asp.net using C# please guide me.
Thanking you support me.
|
|
|
|
|
|
how to check arithmetic ,logical, trigonometric and gromatric
values in nested switching ..
i mean how to use nested switch for the above operators
when i press l it us some logical operation \
and when i press a give some arithmetic operation and so on....
|
|
|
|
|
You are approaching this from the wrong direction. You first need to define your problem and then break it up into the separate parts necessary for a solution. Only then can you decide whether you need any switch statements, let alone nested ones.
Use the best guess
|
|
|
|
|
Can't be solved using a "switch"; this is where we traditionally use the parser-pattern.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Are you looking for something like this,
string Operator = GetOperator();
switch (Operator)
{
case "Sin":
case "Cos":
case "Tan":
{
// do something
switch (Operator)
{
case "Sin":
break;
case "Cos":
break;
case "Tan":
break;
default:
break;
}
break;
}
case "+":
case "-":
case "*":
case "/":
{
// do something
switch (Operator)
{
case "+":
break;
case "-":
break;
default:
break;
}
break;
}
default:
break;
}
|
|
|
|
|
It doesn't matter. Nested selects will not solve the problem he's ultimately trying to solve.
|
|
|
|
|
i many time call method with the help of thread like
static void Main( string[] args )
{
Thread t = new Thread( MyFunction );
t.Start();
}
static void MyFunction()
{
//code goes here
}
and some time i use ThreadPool class also like
System.Threading.ThreadPool.QueueUserWorkItem(delegate {
MyFunction();
}, null);
but i do not understand what is the difference between calling any method with the help of thread class or ThreadPool class
so i am looking a good discussion about what is the difference between Thread & ThreadPool class.also need to know when we should use Thread class to call a method and when ThreadPool class to call any method ? if possible discuss also with sample code with sample situation.
another very important question is that if i start multiple thread then my application performance will become low or bad ? if yes then tell me why...?
now also tell me what is BackgroundWorker class and how it is different from Thread & ThreadPool class. how far i heard that BackgroundWorker class also create a separate thread to run any method. so please discuss how it is different from Thread & ThreadPool class and when one should go for BackgroundWorker class.
here is small sample code of BackgroundWorker
private void button1_Click(object sender, EventArgs e)
{
BackgroundWorker bw = new BackgroundWorker();
// this allows our worker to report progress during work
bw.WorkerReportsProgress = true;
// what to do in the background thread
bw.DoWork += new DoWorkEventHandler(
delegate(object o, DoWorkEventArgs args)
{
BackgroundWorker b = o as BackgroundWorker;
// do some simple processing for 10 seconds
for (int i = 1; i <= 10; i++)
{
// report the progress in percent
b.ReportProgress(i * 10);
Thread.Sleep(1000);
}
});
// what to do when progress changed (update the progress bar for example)
bw.ProgressChanged += new ProgressChangedEventHandler(
delegate(object o, ProgressChangedEventArgs args)
{
label1.Text = string.Format("{0}% Completed", args.ProgressPercentage);
});
// what to do when worker completes its task (notify the user)
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
delegate(object o, RunWorkerCompletedEventArgs args)
{
label1.Text = "Finished!";
});
bw.RunWorkerAsync();
}
tbhattacharjee
|
|
|
|
|
Tridip Bhattacharjee wrote: with the help of thread class or ThreadPool class
The threadpool holds pre-created threads; those always come in handy when programming UI-tasks to do async processing. They're background-threads, and get recycled to the pool when finished. Background-thread get destroyed automatic when your app closes.
If you need something more complex, you'd create your own[^].
Tridip Bhattacharjee wrote: another very important question is that if i start multiple thread then my application performance will become low or bad ?
It doesn't make execution "faster", it creates a new execution-path, one that "might" run on a different CPU (if you have multiple). You'll already need them if you want a nice responsive UI.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Also, spinning up a thread is an expensive operation. Using one out of the threadpool saves you the execution creating one yourself.
|
|
|
|
|
Use a BackgroundWorker if you need to switch between the thread and your UI.
Use threads for long running processes that would be running in the background.
|
|
|
|
|
I've created a small VS 2012 c# project that eventually does a divide-by-zero. I catch the exception and then do a call to MiniDumpWriteDump and it successfully creates a dump file.
Obviously I have the pdb and source files.
What I'd like to do now is load the minidump into VS and then examine it so I can get familiar with how to read it etc. As I understand, the minidump file should be able to display exactly what was going on and using the debugger, I could look at the stack trace and display variables? Double-clicking the minidump file opens it in VS 2012 but I'm really left with the puzzle, what now? Has anyone loaded a dump file before and looked at it in VS?
I've searched for answers but the term minidump is so ubiquitous that it's really not easy to what's relevant to VS and what isn't. I'm led to believe that if I have the dump file and the pdb files and the source then I should be able to see an exact snapshot of went turned tits-up. I just don't really know what's the best way to load it and change any settings to use it. If I can get it working on a simple divide-by-zero app then I can use them in our production app which'll help us deal with fatal problems reported by our users.
TIA.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
PHS241 wrote: Double-clicking the minidump file opens it in VS 2012 but I'm really left with the puzzle, what now?
Now you set the location of the debug-symbols. I got it working using VS2010 and .NET 4, so you should be able to achieve the same.
I followed this[^] tutorial.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|