In the country of Rahmania, the cost of mailing a letter is 40 sinas for letters up to 30 g, 55 sinas for letters over 30 g and up to 50 g, 70 sinas for letters over 50 g and up to 100 g, and then an additional 25 sinas for each additional 50 g or part thereof. Write a program that prompts the user for a mass and then gives the cost of mailing a letter having that mass.
class Mail
{
public static void main (String args[])
{
System.out.println("What is the mass of you letter?");
int mass=In.getInt();
if(mass<30)
{
System.out.println("The cost for mailing your "+mass+"g would be 40 sinas.");
}
else if(mass>30&&mass<50)
{
System.out.println("The cost for mailing your "+mass+"g would be 55 sinas.");
}
else if(mass>50&&mass<100)
{
System.out.println("The cost for mailing your "+mass+"g would be 70 sinas.");
}
else
{
int changingMass=0;
mass=changingMass;
changingMass=changingMass-100;
changingMass=changingMass/50;
int totalSinas=changingMass*25+(70);
System.out.println("The cost for mailing your "+mass+"g would be "+totalSinas+" sinas.");
}
}
}
If i type in like 200 for the mass i get 0g and 20 sinas. Why i even try to read the code and to me it is good. What i think is the problem-changingMass=changingMass/50;
Aucun commentaire:
Enregistrer un commentaire