Basic Java Code


SUBMITTED BY: AhmadMRE

DATE: Jan. 5, 2018, 2:39 a.m.

FORMAT: Text only

SIZE: 792 Bytes

HITS: 6082

  1. public class CodeTesterApp {
  2. public static void main(String args[]) {
  3. // display a welcome message
  4. System.out.println("Welcome to the Code Tester");
  5. System.out.println();
  6. // hard code three values
  7. String productCode = "java";
  8. double price = 49.50;
  9. int quantity = 2;
  10. // perform a calculation
  11. double total = price * quantity;
  12. // display the output
  13. String message =
  14. "Code: " + productCode + "\n" +
  15. "Price: " + price + "\n" +
  16. "Quantity: " + quantity + "\n" +
  17. "Total: " + total + "\n";
  18. System.out.println(message);
  19. // display a goodbye message
  20. System.out.println("Bye!");
  21. }
  22. }

comments powered by Disqus