Asked by Lee
Project: I need help getting start on this project. What I have so far is a mess. It's Do While loops and nested loops.
Table 6.1 shows the different grads of eggs and the minimum weight required for each classification. Write a program that processes the text file EGGS.TXT containing a list of the weights of a sample of eggs. The program should report the number of eggs in each grade and the weight of the lightest and heaviest egg in the sample Figure 6.6 shows a possilbe output of the program. Note: Eggs weighting less than 1.5 ounces cannot be sold in supermarkets. * If you need more details let me know.
Table 6.1 shows the different grads of eggs and the minimum weight required for each classification. Write a program that processes the text file EGGS.TXT containing a list of the weights of a sample of eggs. The program should report the number of eggs in each grade and the weight of the lightest and heaviest egg in the sample Figure 6.6 shows a possilbe output of the program. Note: Eggs weighting less than 1.5 ounces cannot be sold in supermarkets. * If you need more details let me know.
Answers
Answered by
Lee
This is a visual basics project.
Answered by
MathMate
I suppose the table shows the minimum weight in oz. for each grade (A,B,C,.. etc.)
This is what I suggest:
1. Read the grade (as string) and minimum weight (as float) into two arrays. Call the number of entries maxGrade.
2. make a third array called gradeCount, with maxGrade as the maximum subscript.
3. Read in the weight of each egg from eggs.txt, and compare with the weight array using a for-loop. If the weight weight exceeds the array value, increment the gradeCount and exit the for-loop.
4. repeat until the entries of eggs.txt is exhausted.
5. output the gradeCount array with the corresponding grades.
Post you code if you have problems.
This is what I suggest:
1. Read the grade (as string) and minimum weight (as float) into two arrays. Call the number of entries maxGrade.
2. make a third array called gradeCount, with maxGrade as the maximum subscript.
3. Read in the weight of each egg from eggs.txt, and compare with the weight array using a for-loop. If the weight weight exceeds the array value, increment the gradeCount and exit the for-loop.
4. repeat until the entries of eggs.txt is exhausted.
5. output the gradeCount array with the corresponding grades.
Post you code if you have problems.
Answered by
Lee
Thank you I was able to create my program with your suggestions.
Answered by
nuhu
Write the output of the segment of program below
10 Read score
20 Data 60
30 if score<= 49 THEN
40 PRINT "you have failed"
50 ELSELF Score >=50 AND Score<= 59 THEN
60 PRINT "You have c"
70 ELSELF Score>=60 AND Score<=69 THEN
80 PRINT "You have B"
90 ELSE
100 PRINT "You have A"
110 END
10 Read score
20 Data 60
30 if score<= 49 THEN
40 PRINT "you have failed"
50 ELSELF Score >=50 AND Score<= 59 THEN
60 PRINT "You have c"
70 ELSELF Score>=60 AND Score<=69 THEN
80 PRINT "You have B"
90 ELSE
100 PRINT "You have A"
110 END
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.