![]() ![]() The final grade is looks like what you want. Printf("The final grade is %d\n", finalgrade) ![]() Printf("Enter grades for student %d\n", i) You initialize i with 0, but continue until i You use gradenum uninitialized, and for the same reason you are not resetting it for each iteration, so your average calc will go wrong. The class is Intro to C, and we have not covered cout, arrays or anything like that, so I don't think I'm expected to use them for this assignment. And then when I try to run the program anyway, I get stuck in an infinite loop. price of the calculators by taking selling price as input. The idea is that you get the number of students via user input, then the do loop should only repeat that number of times.īut when I compile the program, I get a warning message that 'total' is not used (when, as far as I can see, it is being used!). It is a simple calculator in Java which can perform basic arithmetic operations like addition, subtraction, multiplication and division of two numbers. Java to calculate the amount to be paid by the customer taking printed price as an input. Step 2) Create a new instance of HelloWorld. I think the problem has to do with the main function or something, because when I right click the class in BlueJ and click on void main it will compile correctly. Change the code in your BlueJ class to look like the following. The code compiles with no errors, but it just doesn't print anything. of all the students in that class printed to the BlueJ terminal window. Printf("The final grade is %d", finalgrade) Step 1) Let's explore how we can create a more flexible constructor. scheduling and an implementation of an electronic calculator to discuss these. setLocationRelativeTo(null) // center window on the screen setSize(500, 150) // or pack() setVisible(true) // Print description of the JComponents. Int s, i, grade, total, gradenum, finalgrade I have written the following program: int main()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |