Search Results

Search found 8 results on 1 pages for 'caramel1991'.

Page 1/1 | 1 

  • Having problem with C++ file handling

    - by caramel1991
    Our lecturer has given us a task,I've attempted it and try every single effort I can,but I still struggle with one of the problem in it,here goes the question: The company you work at receives a monthly report in a text format. The report contains the following information. • Department Name • Head of Department Name • Month • Minimum spending of the month • Maximum spending of the month Your program is to obtain the name of the input file from the user. Implement a structure to represent the data: Once the file has been read into your program, print out the following statistics for the user: • List which department has the minimum spending per month by month • List which department has the minimum spending by month by month Write the information into a file called “MaxMin.txt” Then do a processing so that the Department Name, Head of Department Name, Minimum spending and Maximum spending are written to separate files based on the month, eg Jan, Feb, March and so on. and of course our lecturer does send us a text file with the content: Engineering Bill Jan 2000 15000 IT Jack Jan 300 20000 HR Jill Jan 1500 10000 Engineering Bill Feb 5000 45000 IT Jack Feb 4500 7000 HR Jill Feb 5600 60000 Engineering Bill Mar 5000 45000 IT Jack Mar 4500 7000 HR Jill Mar 5600 60000 Engineering Bill Apr 5000 45000 IT Jack Apr 4500 7000 HR Jill Apr 5600 60000 Engineering Bill May 2000 15000 IT Jack May 300 20000 HR Jill May 1500 10000 Engineering Bill Jun 2000 15000 IT Jack Jun 300 20000 HR Jill Jun 1500 10000 and here's the c++ code I've written ue#include include include using namespace std; struct Record { string depName; string head; string month; float max; float min; string name; }myRecord[19]; int main () { string line; ofstream minmax,jan,feb,mar,apr,may,jun; char a[50]; char b[50]; int i = 0,j,k; float temp; //float maxjan=myRecord[0].max,maxfeb=myRecord[0].max,maxmar=myRecord[0].max,maxapr=myRecord[0].max,maxmay=myRecord[0].max,maxjune=myRecord[0].max; float minjan=myRecord[1].min,minfeb=myRecord[1].min,minmar=myRecord[1].min,minapr=myRecord[1].min,minmay=myRecord[1].min,minjune=myRecord[1].min; float maxjan=0,maxfeb=0,maxmar=0,maxapr=0,maxmay=0,maxjune=0; //float minjan=0,minfeb=0,minmar=0,minapr=0,minmay=0,minjune=0; string maxjanDep,maxfebDep,maxmarDep,maxaprDep,maxmayDep,maxjunDep; string minjanDep,minfebDep,minmarDep,minaprDep,minmayDep,minjunDep; cout<<"Enter file name: "; cina; ifstream myfile (a); //minmax.open ("MaxMin.txt"); if (myfile.is_open()){ while (! myfile.eof()){ myfilemyRecord[i].depNamemyRecord[i].headmyRecord[i].monthmyRecord[i].minmyRecord[i].max; cout << myRecord[i].depName<<"\t"< cout<<"Enter file name: "; cinb; ifstream myfile1 (b); minmax.open ("MaxMin.txt"); jan.open ("Jan.txt"); feb.open ("Feb.txt"); mar.open ("March.txt"); apr.open ("April.txt"); may.open ("May.txt"); jun.open ("Jun.txt"); if (myfile1.is_open()){ while (! myfile1.eof()){ myfile1myRecord[i].depNamemyRecord[i].headmyRecord[i].monthmyRecord[i].minmyRecord[i].max; if (myRecord[i].month == "Jan"){ jan<< myRecord[i].depName<<"\t"< if (maxjan< myRecord[i].max){ maxjan=myRecord[i].max; maxjanDep=myRecord[i].depName;} //if (minjan myRecord[i].min){ // minjan=myRecord[i].min; //minjanDep=myRecord[i].depName; //} for (k=1;k<=3;k++){ for (j=0;j<2;j++){ if (myRecord[j].minmyRecord[j+1].min){ temp=myRecord[j].min; myRecord[j].min=myRecord[j+1].min; myRecord[j+1].min=temp; minjanDep=myRecord[j].depName; }}} } if (myRecord[i].month == "Feb"){ feb<< myRecord[i].depName<<"\t"< //if (minfebmyRecord[i].min){ //minfeb=myRecord[i].min; //minfebDep=myRecord[i].depName; //} for (k=1;k<=3;k++){ for (j=0;j<2;j++){ if (myRecord[j].minmyRecord[j+1].min){ temp=myRecord[j].min; myRecord[j].min=myRecord[j+1].min; myRecord[j+1].min=temp; minfebDep=myRecord[j+1].depName; }}} } if (myRecord[i].month == "Mar"){ mar<< myRecord[i].depName<<"\t"< if (myRecord[i].month == "Apr"){ apr<< myRecord[i].depName<<"\t"< if (minaprmyRecord[i].min){ minapr=myRecord[i].min; minaprDep=myRecord[i].min;} } if (myRecord[i].month == "May"){ may< if (minmaymyRecord[i].min){ minmay=myRecord[i].min; minmayDep=myRecord[i].depName;} } if (myRecord[i].month == "Jun"){ jun<< myRecord[i].depName<<"\t"< if (minjunemyRecord[i].min){ minjune=myRecord[i].min; minjunDep=myRecord[i].depName;} } i++; myfile.close(); } minmax<<"department that has maximum spending at jan "< else{ cout << "Unable to open file"< } sorry inside that code ue#include should has iostream along with another two #include fstream and string,but at here it was treated as html tag,so i can't type it. my problem here is,I can't seems to get the minimum spending,I've try all I can but I'm still lingering on it,any idea??THANK YOU!

    Read the article

  • About x86 architecture assembly and others

    - by caramel1991
    I have the wisdom to learn assembly language,so I search through the internet for the information about this language,and came across some page telling that assembly is a low level native language and varied from one to another processor,so I just wonder,I'm currently running an intel based processor,I've no idea whether it is x86 or what,but I just wanna know,Does it possible for me to learn other processor arhchitecture assembly on my pc??Besides,is there any good books that could guide me through learning the intel architecture assembly.

    Read the article

  • About x86 architecture assembly and others

    - by caramel1991
    I have the wisdom to learn assembly language,so I search through the internet for the information about this language,and came across some page telling that assembly is a low level native language and varied from one to another processor,so I just wonder,I'm currently running an intel based processor,I've no idea whether it is x86 or what,but I just wanna know,Does it possible for me to learn other processor arhchitecture assembly on my pc??Besides,is there any good books that could guide me through learning the intel architecture assembly.

    Read the article

  • Arrays in JavaScript

    - by caramel1991
    While reading a book about JavaScript I stumbled across an example: var names = new Array("Paul","Catherine","Steve"); var ages = new Array(31,29,34); var concatArray; concatArray = names.concat(ages); My question is, why doesn't the variable concatArray need to be define as a new Array() in order to store the concatenated data for both arrays name and ages , but when I try to treat the concatArray as an array by adding another line of code "document.write(concatArray[0])", it works just like an array and shows me the data stored in the first element. I just wonder why I'm not declaring the concatArray as a new array, yet it still works as one.

    Read the article

  • Just a small problem regarding javscript BOM question

    - by caramel1991
    The question is this: Create a page with a number of links. Then write code that fires on the window onload event, displaying the href of each of the links on the page. And this is my solution <html> <body language="Javascript" onload="displayLink()"> <a href="http://www.google.com/">First link</a> <a href="http://www.yahoo.com/">Second link</a> <a href="http://www.msn.com/">Third link</a> <script type="text/javascript" language="Javascript"> function displayLink() { for(var i = 0;document.links[i];i++) { alert(document.links[i].href); } } </script> </body> </html> This is the answer provided by the book <html> <head> <script language=”JavaScript” type=”text/javascript”> function displayLinks() { var linksCounter; for (linksCounter = 0; linksCounter < document.links.length; linksCounter++) { alert(document.links[linksCounter].href); } } </script> </head> <body onload=”displayLinks()”> <A href=”link0.htm” >Link 0</A> <A href=”link1.htm”>Link 2</A> <A href=”link2.htm”>Link 2</A> </body> </html> Before I get into the javascript tutorial on how to check user browser version or model,I was using the same method as the example,by acessing the length property of the links array for the loop,but after I read through the tutorial,I find out that I can also use this alternative ways,by using the method that the test condition will evalute to true only if the document.links[i] return a valid value,so does my code is written using the valid method??If it's not,any comment regarding how to write a better code??Correct me if I'm wrong,I heard some of the people say "a good code is not evaluate solely on whether it works or not,but in terms of speed,the ability to comprehend the code,and could posssibly let others to understand the code easily".Is is true??

    Read the article

  • Local and global variables in javascript

    - by caramel1991
    Today,I started to code a page that prompt the user to choose their PC spec,and the code is as follow <html> <title>Computer Specification Chooser</title> <head> <script type="text/javascript"> var compSpec = document.compChooser; function processorUnavailable_onclick() { alert("Sorry that processor speed is currently unavailable"); compSpec.processor[2].checked = true; } </script> </head> <body> <form name="compChooser"> <p>Tick all components you wan included on your computer</p> <p> DVD-ROM <input type="checkbox" name="chkDVD" value="DVD-ROM" /> <br /> CD-ROM <input type="checkbox" name="chkCD" value="CD-ROM" /> <br /> Zip Drive <input type="checkbox" name="chkZIP" value="ZIP DRIVE" /> </p> <p> Select the processor speed you require <br /> <input type="radio" name="processor" value="3.8" /> 3.8 GHZ <input type="radio" name="processor" value="4.8" onclick="processorUnavailable_onclick()" /> 4.8 GHZ <input type="radio" name="processor" value="6" /> 6 GHZ </p> <input type="button" name="btnCheck" value="Check Form" /> </form> </body> </html> The problem I'm facing is on the function that I've tie to the event handler,when I try to choose the radio button of the processor value 4.8 GHZ,yes it alert me with the message inside the function,but after that,it doest not execute the next statement inside the function,that is to check the next processor value 6 GHZ. I've try my effort to change it and test on it,and find out when I set the var compSpec = document.compChooser as a local variable inside the function instead of a global variable,the next statement could be executed. But I thought for a global variable,it is accessible in everywhere on the page and also inside a function.But why now I can't accesses it inside my function??Any idea?? Besides,I stumble upon a weird article while googling,it says that when a global variable is created,it is added to window object.I just curious why this happen??And what's the benefits and uses of it?? THANK YOU

    Read the article

  • Quetion regarding local and global variable in javascript

    - by caramel1991
    Today,I started to code a page that prompt the user to choose their PC spec,and the code is as follow <html> <title>Computer Specification Chooser</title> <head> <script type="text/javascript"> var compSpec = document.compChooser; function processorUnavailable_onclick() { alert("Sorry that processor speed is currently unavailable"); compSpec.processor[2].checked = true; } </script> </head> <body> <form name="compChooser"> <p>Tick all components you wan included on your computer</p> <p> DVD-ROM <input type="checkbox" name="chkDVD" value="DVD-ROM" /> <br /> CD-ROM <input type="checkbox" name="chkCD" value="CD-ROM" /> <br /> Zip Drive <input type="checkbox" name="chkZIP" value="ZIP DRIVE" /> </p> <p> Select the processor speed you require <br /> <input type="radio" name="processor" value="3.8" /> 3.8 GHZ <input type="radio" name="processor" value="4.8" onclick="processorUnavailable_onclick()" /> 4.8 GHZ <input type="radio" name="processor" value="6" /> 6 GHZ </p> <input type="button" name="btnCheck" value="Check Form" /> </form> </body> </html> The problem I'm facing is on the function that I've tie to the event handler,when I try to choose the radio button of the processor value 4.8 GHZ,yes it alert me with the message inside the function,but after that,it doest not execute the next statement inside the function,that is to check the next processor value 6 GHZ,I've try my effort to change it and test on it,and find out when I set the var compSpec = document.compChooser as a local variable inside the function instead of a global variable,the next statement could be executed.But I thought for a global variable,it is accessible in everywhere on the page and also inside a function.But why now I can't accesses it inside my function??Any idea??Besides,I stumble upon a weird article while googling,it says that when a global variable is created,it is added to window object.I just curious why this happen??And what's the benefits and uses of it??THANK YOU

    Read the article

  • What to do to improve my skill and knowledge on javascript??

    - by caramel1991
    Currently I've finish studying the book name "beginning javascript 3rd edition",so i just wonder what should be my next step in order to strengthen myself on using and manipulating this language?Besides,how to improve myself in programming in javascript??Is it by thinking something cool myself,and start coding it??Or googling around the internet to find some task and question offered??Besides,is there any book that teaches the correct method of coding?? Thanks you

    Read the article

1