Using a Decision Control Structure (if), create a flowchart and a java program that
reads a commodity code, quantity of the commodities bought and the unit price and
output the amount to be paid by the customer.
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int commodity_code;
int quantity;
double unit_price;
System.out.println("Enter commodity code: ");
commodity_code=in.nextInt();
System.out.println("Enter quantity of commodity: ");
quantity=in.nextInt();
System.out.println("Enter unit price: ");
unit_price=in.nextInt();
double total_price=unit_price*quantity;
System.out.println("Total price = "+total_price);
}
}
Comments
Leave a comment