public class PQT { public static void main(String[] args) { //declare variables
ID: 3613643 • Letter: P
Question
public class PQT {
public static void main(String[] args) {
//declare variables
doubleprice, total;
int quantity;
String priceString = "49.99";
String quantityString = "15";
//convert variables
double price = (double)priceString;
int quantity =(int)quantityString;
//calculate total
double total = price * quantity ;
//display results
System.out.println("The price is" + price);
System.out.println("The quantity is" +quantity);
System.out.println("The total is" +total);
Explanation / Answer
import java.io.*; import java.lang.*; import java.util.*; public class PQT { public static void main(String[] args) { // declare variables double price, total; int quantity; String priceString = "49.99"; String quantityString = "15"; // convert variables price =Double.parseDouble(priceString); quantity =Integer.parseInt(quantityString); // calculate total total = price * quantity ; // display results System.out.println("The price is" + price); System.out.println("The quantity is" +quantity); System.out.println("The total is" + total); } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.