Slight miscalculation with code for discounts.
in
Programming Questions
•
20 days ago
Greetings yet again!
I come back with yet another problem I managed to solve but not quite, I solemnly promise to help back to the community once I become proficient, till them I ask for more help.
'Tis the code:
'Tis the code:
import javax.swing.*;
double artic;int cant;int tipoClient; // 1 for frecuente, any other for normal..double descNorm = 0.05;double descFrec = 0.10;double subt;double desct;double total;String valor;
valor= JOptionPane.showInputDialog("Enter the article's price.");artic =Integer.parseInt(valor);
valor= JOptionPane.showInputDialog("Enter amount");cant=Integer.parseInt(valor);
valor= JOptionPane.showInputDialog("Welcome to the descount system \n Enter 1, if it is a frecuent costumer, or any other digit for a normal one");tipoClient=Integer.parseInt(valor);
subt= artic * cant;
switch(tipoClient){case 1: desct= subt*descNorm;break;default: desct= subt*descFrec;break;}
total= subt-desct;
JOptionPane.showMessageDialog(null,total);System.exit(0);
Originally the problem said and I quote: "Find the total of an article in discount, if the costumer is a regular apply 10%
if not apply 5%" Problem is that the code is giving me things that it shouldn't as a result, I tried this in raptor first and it worked just well.
Scenario:
Price: 500
Regular: Yes/1
Sie sind das Essen und wir sind die Jäger!
1