Ask your own question, for FREE!
Mathematics 17 Online
OpenStudy (anonymous):

I feel like such a novice. I can't even read basic input. I have a text file with the following data: Paper Dimensions A1 = 33.1 x 23.4 A2 = 23.4 x 16.5 A3 = 16.5 x 11.7 A4 = 11.7 x 8.3 Paper Prices (to nearest dollar) 198 112 189 154 103 I want to read all the heights into an array (so 33.1, 23.4, 16.5, 11.7) and all the widths into another array. I want to also read all the paper prices into an array as well. Here's what I have. I also want to read the paper-size (so 1, 2, 3 or 4 for A1, A2, A3, or A4) into an array, so it'd be {1,2,3,4} Here's my attempt: int n_pap

OpenStudy (anonymous):

This is for C programming language, BTW.

OpenStudy (anonymous):

My attempt: int n_papers = 0; int n_costs = 0; float heights[MAX]; float widths[MAX]; int sizes[MAX]; int costs[MAX]; while (scanf("A%d = %f x %f",&sizes[n_papers],&heights[n_papers],&width[n_papers]) == 3) { n_papers++; } while (scanf("%d",&costs[n_costs])==1) { n_costs++; } And when I test to see if it worked: printf("%d\n",n_papers); printf("%d",n_costs); it says n_papers is 0 and n_costs is 0, so it's essentially saying that it didn't read in anything! Would any of you be able to help me? Thanks a lot.

OpenStudy (anonymous):

I do not know C programming, but I have dabbled in Java programming, one class does not perfect the programming language by any means. From the logic and your result of giving no information, your code is either not pulling the information from your text file or the code that you have to scan through the array entries is not doing its job. Looking at the beginning of your code you are defining the values of the papers int n_papers = 0; int n_costs = 0; Maybe this is overwriting your array? Should you write it as int n_papers =" "; int n_costs = " "; with some sort of return statement to send the values back into those place holders?

OpenStudy (anonymous):

In Java public int hiNumber() { int numb = 0;//Sets numb to array value of 0 for (int i = 0; i < Gamelist.size(); i++){//Checks the array length for highest item number if (get(i).getItem() > numb) { numb = get(i).getItem(); } } return numb; } I switched majors because I did not want to deal with the headache of programming...still have 2 classes to go in programming however lol. Hope that this gets your programming gears turning.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!