Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Code a simple java shopping cart program in 6 minutes! 🛒
Play lesson

Java tutorial for beginners ☕ - Code a simple java shopping cart program in 6 minutes! 🛒

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#java #javatutorial #javacourse import java.util.Scanner; public class Main { public static void main(String[] args) { // SHOPPING CART PROGRAM Scanner scanner = new Scanner(System.in); String item; double price; int quantity; char currency = '$'; double total; System.out.print("What item would you like to buy?: "); item = scanner.nextLine(); System.out.print("What is the price for each?: "); price = scanner.nextDouble(); System.out.print("How many would you like?: "); quantity = scanner.nextInt(); total = price * quantity; System.out.println("\nYou have bought " + quantity + " " + item +"/s"); System.out.println("Your total is " + currency + total); scanner.close(); } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere