Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 16 Online
OpenStudy (anonymous):

i am to write a code in java that prints out a class participation grade for i clicker scores. the best 75% will be chosen and the max grade is 100%. We r to use JOptionPane to ask the user for the input and to read the values for the total amount of clickers question, the number of correct responses, the number of incorrect responses. Each correct question is 2 points and the wrong question is 1 point.please can u help me ??

OpenStudy (anonymous):

Sure, I'll help since I just finished my Computer Science exam today. Only problem is, i'm not really understanding what your code is suppose to do. So you have to ask the student the total amount of responses he made the determine how many are right and wrong? Can I have more information on how to determine which are right and wrong?

OpenStudy (anonymous):

example1: Enter the number of I clicker questions: 4 Enter the number of correct responses: 3 Enter the number of incorrect responses: 0 You got a class participation grade of 100.0% example2: Enter the number of I clicker questions: 100 Enter the number of correct responses: 0 Enter the number of incorrect responses: 100 You got a class participation grade of 50.0%

OpenStudy (anonymous):

example1: Enter the number of I clicker questions: 4 Enter the number of correct responses: 3 Enter the number of incorrect responses: 0 You got a class participation grade of 100.0% example2: Enter the number of I clicker questions: 100 Enter the number of correct responses: 0 Enter the number of incorrect responses: 100 You got a class participation grade of 50.0%

OpenStudy (anonymous):

What value do you want to determine the number of class participation? Like in your first example, your saying that 3/4 = 100% and then 0/100 = 50%. I'm not really getting how that works.

OpenStudy (anonymous):

1 correct answer is 2 points and a wrong answer is 1 point

OpenStudy (anonymous):

1 correct answer is 2 points and a wrong answer is 1 point

OpenStudy (anonymous):

So all your asking in the program is to determine how many points they get?

OpenStudy (anonymous):

yes and the output should show the grade in percentage

OpenStudy (anonymous):

yes and the output should show the grade in percentage

OpenStudy (anonymous):

Oh lol k now I get what you were asking xD well try this out then: Hmm alright. import javax.swing.*; public class iClicker { public static void main (String[] args) { String n = JOptionPane.showInputDialog("Please enter number of iClicker questions: "); int num = Integer.parseInt(n); String n1 = JOptionPane.showInputDialog("Please enter number of correct responses: "); int num1 = Integer.parseInt(n1); int correct = num1*2; String n2 = JOptionPane.showInputDialog("Please enter number of incorrect responses: "); int num2 = Integer.parseInt(n2); int percentage = correct+num2 / num; JOptionPane.showMessageDialog(null, "You got " + percentage + "%!"); } Hope this helps~

OpenStudy (anonymous):

thanks for everything but the output its giving me is not the output i want

OpenStudy (anonymous):

thanks for everything but the output its giving me is not the output i want

OpenStudy (anonymous):

Could you tell me what your output was? The code I wrote was suppose to give the percentage they got.

OpenStudy (anonymous):

when i did dis example2: Enter the number of I clicker questions:100 Enter the number of correct responses: 0 Enter the number of incorrect responses: 100 You got a class participation grade of 50.0% i did not get 50 as the percentage i got 1 as the percentage

OpenStudy (anonymous):

when i did dis example2: Enter the number of I clicker questions:100 Enter the number of correct responses: 0 Enter the number of incorrect responses: 100 You got a class participation grade of 50.0% i did not get 50 as the percentage i got 1 as the percentage

OpenStudy (anonymous):

Oh my bad, I forgot to convert the decimal to a percentage. Here's the new code that's edited: import javax.swing.*; public class iClicker { public static void main (String[] args) { String n = JOptionPane.showInputDialog("Please enter number of iClicker questions: "); int num = Integer.parseInt(n); String n1 = JOptionPane.showInputDialog("Please enter number of correct responses: "); int num1 = Integer.parseInt(n1); int correct = num1*2; String n2 = JOptionPane.showInputDialog("Please enter number of incorrect responses: "); int num2 = Integer.parseInt(n2); int percentage = correct+num2 / num; int precentage2 = percentage*100; JOptionPane.showMessageDialog(null, "You got " + percentage2 + "%!"); } Try this out~

OpenStudy (anonymous):

now the out put is 100 not 50

OpenStudy (anonymous):

now the out put is 100 not 50

OpenStudy (anonymous):

If this is not what you wanted, i'm really confused on what you want. Please be more specific with your question.

OpenStudy (anonymous):

Hopefully this modification of Daebakjoo's code works for you: import javax.swing.*; public class iClicker { static int numQuestions, correctAnswers, incorrectAnswers; static double totalPoints, points, percentage; public static void main (String[] args) { String questions = JOptionPane.showInputDialog("Please enter number of iClicker questions: "); numQuestions = Integer.parseInt(questions); totalPoints = numQuestions*2; String correctAns = JOptionPane.showInputDialog("Please enter number of correct responses: "); correctAnswers = Integer.parseInt(correctAns); points += correctAnswers*2; String incorrectsAns = JOptionPane.showInputDialog("Please enter number of incorrect responses: "); incorrectAnswers = Integer.parseInt(incorrectsAns); points += incorrectAnswers; percentage = (points/totalPoints) * 100; JOptionPane.showMessageDialog(null, "You got " + percentage + "%!"); } }

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!