I am newbie at this, please try to be patient with me. In my class at school we have been trying out various loops in problems. The instructor calls the one we've been using a "Sentinel Loop". If there is another name for it I don't know what it is.
I can get it to accept the input and also the stopping statement. I can even get the program to tell me the sales tax and shipping "on an individual input".
The instructor wants to be able to input several figures and when the stopping statement is triggered, have the program show the total shipping cost and sales tax for all of the inputs together.
I have placed the math parts between the two input statements, and also outside of the loop.
My question is: "Do I need to put the math section into a method and if so where would I place the calling statement so that it would only work after the stop statement is triggered or would something else be even more appropriate?"
I have been beating my head against the wall for the last 10 days, and have not figured out an answer. I have tried everything I can think of.
Can someone either please answer the question or at least steer me to the information on how to do this type of a problem. I would appreciate it greatly.
This is the main body of my sentinel loop program. I can get it to work fine.
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
namespace Exer4Chpt6<br />
class Program<br />
staticvoid Main()<br />
string inValue = "";<br />
double salesAmount = 0;<br />
double salesTax;<br />
double shipAmount = 0;<br />
double grdTotal;<br />
constdouble INTEREST_RATE = .07;<br />
double overAllTotal = 0;<br />
double totalShippingAmt = 0;<br />
double totalSalesTax = 0;<br />
Console.WriteLine("Enter as many different sales amounts ");<br />
Console.WriteLine("as you want. You will be shown the sales ");<br />
Console.WriteLine("amount, sales tax, shipping amount, and ");<br />
Console.WriteLine("the grand total. To Stop, enter");<br />
Console.WriteLine(" -99");<br />
Console.WriteLine("Please type in a sales amount.");<br />
inValue = Console.ReadLine(); // Priming read, input before loop<br />while (inValue != "-99")<br />
salesAmount = Convert.ToDouble(inValue);<br />
salesTax = salesAmount * INTEREST_RATE;<br />
Console.WriteLine("Please type in a sales amount.");<br />
inValue = Console.ReadLine(); // reassigns data in inValue to check in loop<br />
This is the math section of my program that I'm having the trouble with. The problem isn't in the math expressions themselves, but more in the placement to get it to do what I want.
I am using RichTextBox class to display some text, and then I want to syntax highlight whats written to it.
So, i use Find(...) to select required text and then use SelectionFont,SelectionColor to changle font/color of the words i need.
The problem is that when i type, i have to do this when the text changes, and i actually see how text gets selected and changes it's color, and that is very annoying...
So, my question is, how to solve this problem? Maybe i can somehow disable redrawing of control till i completely highlighted control or smthing like ?
We know that Delegate is a Functional Pointer. But i want to pass Member name as a variable to Delegates. The example given below.
*-------------------------------------------------------------------------- using System;
public delegate void MyFunction(int a, int b);
public static void Function1 (int x, int y)
public static void Function2 (int x, int y)
public static void Function3(int x, int y)
static void Main(string args)
int i = 1;
string Fstring = "Function";
for ( i=1; i<=3; i++)
MyFunction mObj = new MyFunction(@(nString));
In the above example, i am storing each function name into "nString" variable.
While creating instance, can i pass this variable name as a parameter. Because the variable name contains name of the function. Or i want to evaluvate the variable nString and execute the function name which i stored in "nString" variable.
If any solution or suggession please write to: firstname.lastname@example.org
I recently had a series of very good interviews with a company I was very excited about and was told I was the top candidate for the senior position. At the end of the interview I was given the assignment below and I was told to zip up the files and return them to the project manager for review when I was done. I was open in the interview that I had no experience in unit testing. I was assured this was no problem and I could omit that portion of the exercise. However, I opted to give it a shot - an opportunity to show I was a quick and willing learner when needed.
After I turned in the "assignment" to the project manager, I was told that after reviewing the code I would be passed over for the position.
I would be VERY appreciative of any feedback anyone might have as to what's wrong with my sample project? I have worked for the same small company for over 6 years and had no experience when I did, so I don't know if there's something I did that killed it for me. I bear no ill will to the company I interviewed for and I have removed any indications from any text that might indicate who the interview was with. But I still must continue to interview and if I'm doing something wrong, I want to nip it in the bud.
Please, don't spare my feelings, I would really appreciate some constructive criticism.
1) Read an ascii text file named “Hire_input.txt” that contains a list of numbers with values between 0 and 100, each number separated by a cr/lf
Sample input (Hire_input.txt)
2) Sort the numbers in ascending order and write the results to an output file named “Hire_Ascending.txt”. Format the file in the same manner as the input file (cr/lf delimiters).
Sample output (Hire_Ascending.txt)
3) Group the numbers by their value and produce a histogram list providing the count of how many numbers of each value were read. Write the output to a file named “Hire_histogram.txt”, formatted using cr/lf delimiters.
Sample output (Hire_histogram.txt)
1 – 1
6 – 2
12 – 1
22 – 1
54 – 1
• Name the program Hire_exercise.exe
• No user interface is required, the program will be run from the console should require no command line parameters to execute normally
• Assume that all files (input and output) will be found/created in the same directory as the program executes
• As part of the exercise, you are expected to write unit tests appropriate for the task.
• Use the development tools of your choice.
• You may not use any external libraries with the exception of standard I/O and a unit testing framework (if you choose).
• You may not use any built-in data structures such as lists, vectors, queues etc. You must build your solution using basic types such as integers, strings and arrays.
• You may not use any built-in sort or histogram functions.
• Please submit all available aspects of your work (source, buildfiles, executables, test input/output etc)
Haven't the foggiest idea what may have changed their mind so quickly. I looked through it, and it seems good to me. The only thing that I noticed that didn't follow the "Additional Notes" was the naming of the program to Hire_excercise.exe...
Regarding the program name, I changed the assignment text to remove the initials of the company, but didn't change the source code or output - the name of the program is what the original assignment asked for. But like I said, don't spare my feelings
Not sure if this is something you would consider, but why not call or email the Project Manager and ask what exactly the deal breaker was? Couldn't hurt to get some feedback so you can improve in the future...
Given the constraints of the project I don't see anything really wrong with the code. It seems fairly well written, well commented (which is really nice) and uses two dimentional arrays - which is something I wouldn't have thought of. I'd have created a class to hold the number and the repetitions and store that in an object array.
For someone that's never written unit tests before your tests are fairly good. They aren't too complex, it is easy to see what each of them does. Obviously, you'd need a bit of guidance, but your give-it-a-go attitude shows me that you are willing to try new things. That, to me, is very important for a software developer. Technology moves on at breakneck speed these days and software developers need to keep up.
Obviously, without seeing the other assignments the other candidates turned in I can't say one way or another whether theres were better or not. However, a few months ago the company I work for went on a recruitment drive and it was shocking the quality of work that was handed in. We do the technical test first - and based on what I see here, I know that you'd be in the short list of the second interview. (The assignment we give is to write a small WinForms application. It is of similar complexity, but we encourage the use of what ever is in the .NET Framework).
Thanks, I appreciate your feedback. Especially since I've read many of your posts and have seen that you know what you're talking about.
I had considered creating a class or struct for the histogram, but figured the simplicity and straight-forwardness of an array was a good idea. Plus, I assumed that the injunction against built-in data structures meant I had to show I new how to use an array efficiently. Once I figued I would be using nothing more than a multi-dimensional array there didn't seem any point in wrapping it in a class and going through all the work of implementing the interfaces that were already supported by arrays from the get-go.
Obviously, because I'm new to interviewing this was a bit of a blow to my ego. But from the responses to this post, I figure I can just suck it up and move on. It's all part of the process and everybody's got to go through it. Up 'til now I've been lucky to get by pretty easy, so thank you again.
The core thing to remember is, you have no control over who else applied. There's not necessarily a problem with your code, someone else may have come along who, for some reason, seemed a better proposition.
I would definately pursue them to ask why you didn't get the job, it shows that you're looking to improve yourself and open to feedback. It could open future doors there as well as give you some feedback on their thinking.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Last Visit: 31-Dec-99 18:00 Last Update: 27-Oct-21 23:30