The program compiles correctly however, it does not give the total cost. import
ID: 3653371 • Letter: T
Question
The program compiles correctly however, it does not give the total cost. import java.util.*; import javax.swing.JOptionPane; import java.lang.*; public class conferenceRegistrationSystem { public static void main(String [] args) { double cost; double totalcost; int choose; String strInput; String strInput1; choose=0; while(choose<1||choose>4) { strInput = JOptionPane.showInputDialog(null,"Select registration type: 1. General registration 2.Student registration 3.General registration with night dinner and keynote speech 4. Student registration with night dinner and keynote speech "); choose=Integer.parseInt(strInput); } if(choose == 1) { cost=895; } else if(choose == 2) { cost=495; } else if (choose == 3) { cost=925; } else cost = 525; JOptionPane.showMessageDialog(null,"Your registation type is:$"+cost); choose=0; while(choose<1||choose>3 ) { strInput1=JOptionPane.showInputDialog(null,"Select Optional preconference workshop 1. Introduction to E-Commerce 2.The Future of the Web 3. Advanced Java Programming 4.Network Security "); choose=Integer.parseInt(strInput1); } if(choose == 1) { totalcost=(295+cost); } else if(choose == 2) { totalcost=(295+ cost); } else if (choose == 3) { totalcost=(395+ cost); } JOptionPane.showMessageDialog(null,"Your total registration type is:$"+ "totalcost"); } }Explanation / Answer
this seems to be working..
import java.util.*;
import javax.swing.JOptionPane;
import java.lang.*;
public class conferenceRegistrationSystem {
public static void main(String [] args) {
double cost; double totalcost; int choose; String strInput; String strInput1; choose=0;
while(choose<1||choose>4) {
strInput = JOptionPane.showInputDialog(null,"Select registration type: 1. General registration 2.Student registration 3.General registration with night dinner and keynote speech 4. Student registration with night dinner and keynote speech ");
choose=Integer.parseInt(strInput);
}
if(choose == 1) { cost=895; }
else if(choose == 2) { cost=495; }
else if (choose == 3) { cost=925; }
else cost = 525;
JOptionPane.showMessageDialog(null,"Your registation type is:$"+cost);
choose=0;
totalcost= 0;
while(choose<1||choose>3 ) {
strInput1=JOptionPane.showInputDialog(null,"Select Optional preconference workshop 1. Introduction to E-Commerce 2.The Future of the Web 3. Advanced Java Programming 4.Network Security ");
choose=Integer.parseInt(strInput1);
}
if(choose == 1) { totalcost=(295+cost); }
else if(choose == 2) { totalcost=(295+ cost); }
else if (choose == 3) { totalcost=(395+ cost); }
JOptionPane.showMessageDialog(null,"Your total registration type is:$"+ totalcost);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.