Saturday, May 9, 2009

Code c# ? help with c# code Notepad ?

Can you share for me code of Notepad by C# ? Thank you

Code c# ? help with c# code Notepad ?
I presume you want to create a "notepad" application using C#. If you do a good sample is available at http://www.freevbcode.com/ShowCode.asp?I... .


Help with C# code?

im having trouble with this code can anyone tell me what I'm doing wrong?





using System;





namespace JenkinsNutShop


{





class NutSales


{





static void Main()


{


// this is where I am listing the name of the business:


Console.WriteLine("JENKINS NUT SHOP");





string customerName;


double pounds;


double subTotal = 0;


string nutName = "";


char nutType;


double totalPrice;


double tax;














GetUserInput(out customerName, out nutType, out pounds);


CalcNutCosts(pounds, nutType, ref subTotal, ref nutName, out totalPrice, out tax);


DisplayReceipt(pounds,nutName,subTotal, tax, totalPrice);


}





public static void GetUserInput(out string customerName, out char nutType, out double pounds)


{


string userin;


// Prompting user for type of nuts they want to purchase:


Console.WriteLine(); //this is making a blank line


// Prompting user for the number of pounds they are ordering :


// Prompting user to input pounds of puchase





Console.Write("Customer name: ");


customerName = Console.ReadLine();


Console.WriteLine("What type of nuts would you like?");


Console.WriteLine("Please type an upper case letter or lower case letter to represent the nuts you wish to buy");


Console.WriteLine("Type in the letter \"C\" for Cashews");


Console.WriteLine("Type in the letter \"A\" for Almonds");


Console.WriteLine("Type in the letter \"P\" for Peanuts");


Console.WriteLine("Type in the letter \"W\" for Walnuts");


Console.WriteLine(); // enters a black line


Console.Write("Nut Type: ");


userin = Console.ReadLine();


nutType = Convert.ToChar(userin);


Console.Write("How many pounds would you like? ");


userin = Console.ReadLine();


pounds = Convert.ToDouble(userin);

















}





public static void CalcNutCosts(double pounds, char nutType, ref double subTotal, ref string nutName, out double totalPrice, out double tax)


{


const double CASHEWS = 6.50;


const double ALMONDS = 7.25;


const double PEANUTS = 2.39;


const double WALNUTS = 2.79;





switch(nutType)


{


case'C':


case'c':





subTotal = pounds * CASHEWS;


nutName = "Cashew";


break;





case'A':


case'a':


subTotal = pounds * ALMONDS;


nutName = "Almonds";


break;





case'P':


case'p':


subTotal = pounds * PEANUTS;


nutName = "Peanuts";


break;








case'W':


case'w':


subTotal = pounds * WALNUTS;


nutName = "Walnuts";


break;





tax = subTotal * .0675;


totalPrice = subTotal + tax;














}


}


























public static void DisplayReceipt(double pounds,string nutName,double subTotal, double tax, double totalPrice)


{








Console.WriteLine();


Console.WriteLine();





Console.WriteLine("Your receipt:");


Console.WriteLine();





Console.WriteLine("{0} pounds of {1} nuts. Subtotal \t {2:C}", pounds, nutName, subTotal);


Console.WriteLine(" Tax \t {0:C}",tax);


Console.WriteLine(" Total \t {0:C}",totalPrice);





Console.WriteLine();


Console.WriteLine("Thank you for shopping at Jenkins Nut Shop \n \n");


}


}


}

Help with C# code?
As previously noted, no one wants to wade through code like this.





Please provide any specific error messages or things that are happening that you don't want to have happen.





And please, post your code on a Web server:





http://www.dougv.com/blog/2006/12/13/a-r...
Reply:One problem i notice is that in your CalcNutCosts function these statements are unreachable:


tax = subTotal * .0675;


totalPrice = subTotal + tax;





because you have your break; statement above them but you have the closing } for the switch statement after them and since you used the parameter modifier out on tax and totalPrice you will get an error because you are unable to set their values. Try moving the closing } of your switch statement after the break; but before where you set the value of tax and totalPrice like this:





case'W':


case'w':


subTotal = pounds * WALNUTS;


nutName = "Walnuts";


break;





}





tax = subTotal * .0675;


totalPrice = subTotal + tax;





}
Reply:That's a lot of code to eye over. Any specifics on the issue?


Required Code in language C for driving a hardware ckt. connected through serial or parllel port?

can someboday give me programme code in Language C and the ckt. diagram of optocouplar driven realy ckt. that i can run by using C programming?





Actually, i want to operate a relay with the help of C programming language , now the signal through the parllel or serial port will not be enough to drive the relay , so i need an electronic circuit that will accept the signal from the parllel or serial port and them amplify it or process it and make the signal so strong , so that it can further operate the relay. this electronic circuit will contain optocouplar IC in oder to have isolation between relay circuit and Computer,


So can somebody provide me some link or can email me this circuit diagram and programming Language C code for operating this circuit?

Required Code in language C for driving a hardware ckt. connected through serial or parllel port?
The simplest thing is to use simple driving CCT, using Transistor to drive relay, and don't forget to put a diode to kill the magnetic feedback of the relay coil (free wheeling diode).


You may search the internet for such CCT.





The programming is the funniest part, where you play with the logic binary to control the relay(s)





regards,


:)
Reply:Its so simple its not funny





you use a 9 pin comm port


send a DTR signal to it


a single transistor inverts the logic and


provides the current for the relay coil





I did that over 20 years ago when I invented


the cash drawer that opened by program command


on an 8 bit Atari computer . Later modified it so


it would work on Novell Network Stations


so Video stores could use them.


Added a modem port DTR command to the end of the printer routine. after reciept printed drawer opened





Find the Line feed pin in your centronics port and use the


printer line feed command to change state of pin


will go high for a short duration . feed the high into a NPN


transistor with a good voltage supply at collector


coil voltage will appear at emitter until base goes low


C++ code that checks if-else syntax of any c/c++ file???

i have to make a code that checks if-else syntax of a c/c++ file. Its taking a lot of time. Is it available somewhere? Or any kind of help is appreciated.





Thank you

C++ code that checks if-else syntax of any c/c++ file???
wud u plz clear ur question
Reply:get it for free


http://www.planet-source-code.com/vb/def...

redbud

Changing Visual C++ code to Visual Basic 2005 Code?

Hi, i found this code but it says for for C++ but i have visual basic 2005 and i need your help to convert it into visual basic 2005.





Can someone please convert it into visual basic 2005 code





here is the code





the website is





http://geekswithblogs.net/kobush/article...





the codes in yellow background are the codes that i need to convert. can someone please convert those codes, put together, and reply over here with the visual basic 205 form of that coding.





thanks bye





please help me

Changing Visual C++ code to Visual Basic 2005 Code?
You'd be better off finding what you want to do in VB.


C code question (about variable assignment)?

Be given the code below:





#include%26lt;stdio.h%26gt;


struct test{


unsigned a:3, b, c;


};


void main(){


struct test x;


x.a = x.b = x.c = 10;


printf("%d %d %d ", x.a, x.b, x.c);


x.c = x.a = x.b = 10;


printf("%d %d %d", x.a, x.b, x.c);


}





/*


PRINTS:


2 10 10 2 10 2


*/





After laborious Google searches, still couldn't find exactly what the ":" in "a:3" struct declaration does. Anyone have an idea?

C code question (about variable assignment)?
It's for so-called "bit fields".





:: unsigned a:3;


basically means that variable 'a' will be three bits wide.





It's almost as evil as goto (because its completely unportable), so you shouldn't use it for real software.


Urgent..change C++ code to C?

hi,


My friend did this program for me in C++ ,and he doesnt know any thing about C,


then our lecturer told me the whole code should be in C language,so I changed some of it and the rest I couldnt .





I couldn't find library in C instead of


#include %26lt;Conio.h%26gt;





also there are some functions should be manipulate it .Can you help me plz?





i put the whole code in this link:


http://www.freewebs.com/radicalfunction/...





ur help highly appreciated..

Urgent..change C++ code to C?
Here is the source that compiles under C.





I had to write the clrscr function, defined the getch macro, change Stdio.h to stdio.h, deleted the Conio.h line. Then it worked.








http://www.thehansens.com/free/DealMatri...
Reply:conio.h works with c


your code seems almost working in c


save the program with c extension and the run it


it will work i think if not by errors u can see wats wrong and it would be easy for u to change
Reply:First, in order for your functions to follow your main(), you need to include function prototypes. You'll get a compiler error about not knowing what your functions are. Either move all of your functions above main() OR include function prototypes above the main() function as in:





int menu(void);





Next, clrscr(); is not an ansi function and won't be recognized by many compilers. You either need to figure out what the correct escape sequence is to clear the screen and include that in a printf statement, or issue something like system("cls");





Lastly, the exit() call requires stdlib.h


I have a problem with my C# code. Could anyone offer a little wisdom as to how I can fix it.?

int upc1, upc2, upc3, upc4, upc5, upc6, upc7, upc8;





DateTime reorderDate;


string code = txtUpc.Text;





try


{


upc2 = int.Parse(code.Substring(0, 1));


upc3 = int.Parse(code.Substring(1, 1));


upc4 = int.Parse(code.Substring(2, 1));


upc5 = int.Parse(code.Substring(3, 1));


upc6 = int.Parse(code.Substring(4, 1));


upc7 = int.Parse(code.Substring(5, 1));


upc8 = int.Parse(code.Substring(7, 1));


}


catch


{


MessageBox.Show("UPC must be in the format mmmppp-c.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);


txtUpc.Focus();


return;


}





bool upcLength = ((code.Length == 8) %26amp;%26amp; (code.Substring(6, 1) == "-"));








if (!upcLength)


{


MessageBox.Show("UPC must be in the format mmmppp-c.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);


txtUpc.Focus();


}


{


}





int num1 = (upc2 + upc4 + upc6) * 5;


int num2 = upc3 + upc5 + upc7;


int num3 = num1 = num2;


int num4 = 10 - (num3 % 10);





if (num4 != 10)


{


MessageBox.Show("UPC must be in the format mmmppp-c.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);


txtUpc.Focus();


}


else


{


}





if (num4 == upc8)


{


txtDescription.Focus();


}


else


{


}

I have a problem with my C# code. Could anyone offer a little wisdom as to how I can fix it.?
int num3 = num1 = num2;





That line is the culprit. Just before that, you assigned two different values to num1 and num2. Then why are you assigning num1 the same value as num2 now? Looks funny. Hence, there is your problem. To fix this, you need to find out what's the real algorithm. May be





int num3 = num1 - num2





??





or





int num3 = num1 + num2





??





something like that?
Reply:Pretty sure your problem lies in these 3 lines somewhere.


int num3 = num1 = num2;


int num4 = 10 - (num3 % 10);


if (num4 != 10)





the firstline I don't understand why you did some calculation for num1 and then assigned num2 to num3 and num1...you just lost the result from the first calculation and num1, num2, and num3 now all hold the same value.





I would make sure that what is stored in num3 can be evenly divided by 10 (10,20,30, 340, etc)

sundew

What is the c++ code runnable in dev c++ developmental tool, for this output????

What is the c++ code runnable in dev c++ developmental tool, for this output????








(it will be like this if the number of amount of string is an even number. and prints like a shape of a hour glass)





enter string: ccss


c c


c


s


s s





enter string: ccss


c c


c


s


s s





(it will be like this if the number of amount of string is an odd number)








enter string: table


t t t


a a


b


l l


e e e








(note: it should be 3 strings to be accepted as input(string) in this program)





Additional Details





1 week ago


What is the c++ code runnable in dev c++ developmental tool, for this output????


what is the c++ code runnable in dev c++ developmental too, for this output????


it will accept a string and creates a figure,, like in the following:





(it will be like this if the number of amount of string is an even number. and prints like a shape of a hour glass)





enter string: ccss


c c


c


s


s s

What is the c++ code runnable in dev c++ developmental tool, for this output????
do an if mod 2 on the string length to figure out if it is even or odd, if it is even generate two strings from the original by going from 0 to length/2 and length/2 to length.





For output cout from within 2 loops, one after the other, the first loop dealing with the first substring, the second loop dealing with the second substring.





The loop will simply start at the length of the substring and decrement to 0, each time printing length number of characters from the substring to the screen.





The second loop will do the same but in reverse, starting at 1 and stoping at length.





Don't understand what you ment for odd numbers but it will be similar to the above.


..........C++ code?

How would I get it to do display the following patterns using the FOR statement?








*********


********


*******


******


so on…





*********


********


*******


******


so on…





Such as:


*


**


***


****


*****


so on…





I have tried using the WHILE for several hours. Unknowing I had to use the FOR all along.





#include %26lt;iostream%26gt;





using std::cout;


using std::cin;


using std::endl;





[code]


int main()


{


//declare variables


const char asterk = '*';


int a = 9;


int b = 0;





while (a %26gt; 0)


{


b = a;


while (b %26gt; 0)


{


cout %26lt;%26lt; asterk;


b = b - 1;


}


a = a - 1;


cout %26lt;%26lt; endl;


}


//end while





return 0;


} //end of main function

..........C++ code?
//Decreasing


int main()


{


//declare variables


const char asterk = '*';


int a = 0;


int b = 0;





For(a = 9;a %26gt; 0 ; a--)


{


For(b=a;b %26gt; 0 ; b--)


{


cout %26lt;%26lt; asterk;


}


cout %26lt;%26lt; endl;


}


//end while





return 0;


} //end of main function





//Increasing


int main()


{


//declare variables


const char asterk = '*';


int a = 0;


int b = 0;





for(a = 1; a %26lt; 9;a++)


{


for(b = a; b %26gt; 0 ;b--)


{


cout %26lt;%26lt; asterk;


}


cout %26lt;%26lt; endl;


}


//end while





return 0;


} //end of main function
Reply:assume the max possible number of * on a line is n.





1) descreasing:





for(int i=n; i%26gt;0; i--)


for(int j=0; j%26lt;i; j++)


cout%26lt;%26lt;"*";


cout%26lt;%26lt;endln;





2) increasing:





for (int i=0; i%26lt;n; i++)


for (int j=0; j%26lt;i; j++)


cout%26lt;%26lt;"*";


cout%26lt;%26lt;endln;


C++ code???

I have to write a program for my class that reads a file that contains words and numbers. Once they are read in I have to use either peek() or putback() to determain weather or not they are words or numbers and then take them and put them in to 2 different files.





With the code that I have attemted to write I cant get the whole word or number to get put in to the file I get something like this





In the file I have hello 543


the output I get for this is


h


e


l


l


o





5


4


3


3


rather then


hello


543





how do I use these to functions to write the code???





Thanks


Nick

C++ code???
Well, your output has a newline or '\n' after each char. That's why the printout looks like that. And you are getting the last char read twice. make sure you read until EOF





You should read the file by char. If you use the peek, you get one char, determine what it is, say a char and then peek at the next, if its a char, get it, if not put it back and get the next char. Loop through till end of file. Close file.








Then open File do the same thing for numbers. Then each will have their own file.
Reply:u must have used line feed dont use line feed
Reply:actually it depends upon your code.. what u r using.. so better to give description of the code.


but it seems to be..that there might be a mistake in declaring variable type.. like int,or float. etc.


also check foe getch(); and clrscr(); library functions
Reply:Question to your question actually, what function are you using to put the characters into the file? I'm sure people could be much more helpful if you are willing to post the code you do have so far.
Reply:peek() returns one integer at a time. That integer represents the ascii character code. If you're using peek to read in a whole line, you'll have to read until you see the newline character '\n'.