LabExer2 AMP 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Pacia, Ann Marie D.

BT2101

Laboratory Exercise

Classes and Methods

import java.util.*;

public class ClassesandMethods {

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

String itemName;

double itemPrice;

int itemQuantity;

double amountDue;

This study source was downloaded by 100000881117976 from CourseHero.com on 02-28-2024 07:45:19 GMT -06:00

https://www.coursehero.com/file/115021522/LabExer2-AMP2docx/
System.out.println("Enter the name of the item you are purchasing.");

itemName = s.nextLine();

System.out.println("Enter the quantity and price separated by a space.");

itemQuantity = s.nextInt();

itemPrice = s.nextDouble();

System.out.println("You are purchasing " + itemQuantity + " " + itemName + "(s) at " +
itemPrice + " each.");

amountDue = itemQuantity * itemPrice;

System.out.println("Amount due is " + amountDue);

This study source was downloaded by 100000881117976 from CourseHero.com on 02-28-2024 07:45:19 GMT -06:00

https://www.coursehero.com/file/115021522/LabExer2-AMP2docx/
Powered by TCPDF (www.tcpdf.org)

You might also like