Make a flowchart
import java.util.Scanner;
public class CommodityCode{
public static void main(String[] args){
Scanner X = new Scanner(System.in); System.out.println("Enter commodity code:"); char code=X.next().charAt(0); System.out.println("Enter quantity of commodity:"); float quantity=X.nextFloat (); System.out.println("Enter unit price:"); float price=X.nextFloat();
float total = quantity * price;
switch(code){ case 'X': double discount = total * .08; System.out.println ("Amount to be paid is :"+ (total - discount)); break; case 'Y': double tax = total * .11; System.out.println ("Amount to be paid is :"+ (total + tax)); break; case 'Z': System.out.println ("Amount to be paid is :"+ price * quantity * 1); break;
default : System.out.println ("Invalid Code");
}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here