from_scratch

println print in the System.out object

Sep 1st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package com.anoldwebsite;
  2.  
  3. public class CodeTesterApp {
  4.  
  5.     public static void main(String args[]) {
  6.         // display a welcome message
  7.         System.out.println("Welcome to the Code Tester");
  8.         System.out.println();
  9.  
  10.         // hard code three values
  11.         String productCode = "java";
  12.         double price = 49.50;
  13.         int quantity = 2;
  14.  
  15.         // perform a calculation
  16.         double total = price * quantity;
  17.            
  18.         // display the output
  19.         String message =
  20.             "Code:     " + productCode + "\n" +
  21.             "Price:    " + price + "\n" +
  22.             "Quantity: " + quantity + "\n" +
  23.             "Total:    " + total + "\n";
  24.         System.out.println(message);
  25.  
  26.         // display a goodbye message
  27.         System.out.println("Bye!");
  28.     }
  29. }
  30.  
  31. //Now do the exercise on the link below. Copy the link and paste it in a browser and then log in.
  32. https://repl.it/student_embed/assignment/3760944/009090c415ba8596291817f427f86e73
Advertisement
Add Comment
Please, Sign In to add comment