Java:j'ai pb avec mon if statements

domxaline -  
 domxaline -
Bonjour,
bonjour
j'ai pb avec mon programme if statements
une partie de programme "mill" marche bien
la partie du 'handloom" me donne aucun réponse reste muet
quelqu'un peut aider svp

import java.io.*;
public class Purchase 
{
	double bill;
	String str;
	String str_discount="";
	public Purchase()
	{ 
		try
		{ 
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			System.out.println("Enter the amount of bill:");
			bill=Double.parseDouble(br.readLine());
			System.out.println("Enter the types of clothe");
			str=br.readLine();
			
			if(str.equalsIgnoreCase("handloom"))
			{ 
				if(bill>=0&& bill <=100)
				{ 
					bill=bill-(bill*5)/100;
					str_discount="5%";
				}
				if(bill>=100&& bill <=200)
				{ 
					bill=bill-(bill*7.5)/100;
					str_discount="7.5%";
				}
				if(bill>200&& bill <=300)
				{ 
					bill=bill-(bill*10)/100;
					str_discount="10%";
				}
				if(bill>300)
				{ 
					bill=bill-(bill*15/100);
					str_discount="15%";
				}
				
				}
			if(str.equalsIgnoreCase("mill"))
			{
		System.out.println("enter");
		{ 
			if(bill>=0&& bill <=100)
			{ 
				bill=bill;
				str_discount="0%";
			}
			if(bill>=100&& bill <=200)
			{ 
				bill=bill-(bill*5)/100;
				str_discount="5%";
			}
			if(bill>200&& bill <=300)
			{ 
				bill=bill-(bill*7.5)/100;
				str_discount="7.5%";
			}
			if(bill>300)
			{ 
				bill=bill-(bill*10/100);
				str_discount="10%";
			}
		}
		System.out.println("The discount is:"+str_discount);
		System.out.println("The final bill after discount is:"+bill);
		}}
			catch(Exception e)
			{ 
				System.out.println("Exception is:"+e);
			}
		    }
	public static void main (String args[])
	{
	
	{
		Purchase pur=new Purchase();
	}
	}}

A voir également:

3 réponses

domxaline
 
en exécutant : Resultat de mon programme est suivante

Enter the amount of bill:
100
Enter the types of clothe
mill
enter
The discount is:5%
The final bill after discount is:95.0

mais en demandant :

Enter the amount of bill:
100
Enter the types of clothe
handloom
????????????

il n'ya aucune réponse
0
KillerKlown Messages postés 48 Statut Membre 12
 
C'est juste parce que tes system.out sont dans le "if mill".

Tu dois corriger les accolades :
}
System.out.println("The discount is:"+str_discount);
System.out.println("The final bill after discount is:"+bill);
}}

en

} }
System.out.println("The discount is:"+str_discount);
System.out.println("The final bill after discount is:"+bill);
}
0
domxaline
 
j'ai ajouté
System.out.println("The discount is:"+str_discount);
				System.out.println("The final bill after discount is:"+bill);

dans le
if(str.equalsIgnoreCase("handloom"))

maintenant pb marche bien
0