Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Dvd Rental Program help?

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Dvd Rental Program help?

    import java.util.*;
    public class DVD_Rental_Program {
    static Scanner kb= new Scanner(System.in);


    public static void main(String[] args) {
    int a,b,c,d,e, day, movLen;
    double total, movCharge;
    String movTitle, movDate;
    boolean flag = true;
    while (flag) {
    mainMessage();
    a = kb.nextInt();
    switch (a) {
    case 1:
    genre();
    b = kb.nextInt();

    switch (b){ // for the HORROR
    case 1:
    horror();
    c = kb.nextInt();


    switch (c) //inside horror
    {
    case 1://horror 1
    System.out.println("****************************** ***********");
    movTitle = "Drag Me To Hell";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 90;
    movCharge = 4.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "August 2009";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $4.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();
    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    }
    break;

    case 2: //inside horror 2
    System.out.println("****************************** ***********");
    movTitle = "Paranormal Activity";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 105;
    movCharge = 5.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "October 2009";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $5.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();


    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    }
    break;

    case 3: //inside horror 3
    System.out.println("****************************** ***********");
    movTitle = "Shutter";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 95;
    movCharge = 3.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "June 2008";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $3.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();
    }

    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    break;
    }// end of horror
    break;


    case 2://for love
    love();
    d = kb.nextInt();

    switch (d)//inside love
    {
    case 1:
    System.out.println("****************************** ***********");
    movTitle = "P.S I Love You";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 120;
    movCharge = 4.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "Feburary 2009";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $4.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();
    }

    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    break;

    case 2:
    System.out.println("****************************** ***********");
    movTitle = "500 Days Of Summer";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 105;
    movCharge = 5.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "September 2009";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $5.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();
    }

    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    break;

    case 3:
    System.out.println("****************************** ***********");
    movTitle = "The Notebook";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 95;
    movCharge = 3.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "April 2005";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $3.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();
    }

    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    break;

    }
    break;

    case 3:
    thriller();
    e = kb.nextInt();

    switch (e)
    {
    case 1:
    System.out.println("****************************** ***********");
    movTitle = "2012";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 150;
    movCharge = 5.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "November 2009";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $5.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();
    }

    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    break;

    case 2:
    System.out.println("****************************** ***********");
    movTitle = "The Day After Tomorrow ";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 125;
    movCharge = 4.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "March 2007";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $4.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();
    }

    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    break;

    case 3:
    System.out.println("****************************** ***********");
    movTitle = "Gamer";
    System.out.println("Desired Movie: "+movTitle);
    System.out.println("-----------------------------------------");
    System.out.println("Length Price Per Day");
    movLen = 90;
    movCharge =5.00;
    System.out.println(movLen+" min S$"+ movCharge);
    System.out.print
    ("Please select desired days to rent(1-9): ");
    day = kb.nextInt();

    if (1 <= day && day<=9)
    {
    System.out.println("Booking Information");
    System.out.println("****************************** ***********");
    System.out.println("Title: "+movTitle);
    System.out.println("Length: "+movLen+" minutes");
    movDate = "September 2009";
    System.out.println("Movie Release Date: "+movDate);
    System.out.println("Number of days rented:"+day);
    System.out.println("Rental fee per day: $5.00");
    total = day * movCharge;
    System.out.println("Total:$"+total);
    System.out.println("****************************** ***********");
    System.out.println(" ");
    System.out.println("(1) Confirm");
    System.out.println("(2) Redo");
    System.out.print("Please select your choice(1-2): ");
    a = kb.nextInt();
    }

    if (a==1)
    {
    ok();
    }
    if (a==2)
    {
    defInOp();
    b = kb.nextInt();
    }
    if(day>9)
    {
    defInOp();
    b = kb.nextInt();
    }
    break;

    default:
    defInOp();
    b = kb.nextInt();
    }

    case 4:
    {
    mainMessage();
    }
    }
    break;
    case 2:
    System.out.println("You have rented the following DVD title(S):");
    System.out.println("****************************** *************");
    System.out.println(" ");
    System.out.println("DVD Title: <"+movTitle +"> Rented for "+day +" day(s).");
    total=
    System.out.println("Payment of S$"+total +" is approved");
    System.out.println("-------------------------------------------");
    flag = false;
    break;

    default:
    System.out.println("Sorry Please Key in the correct value.");
    }

    } // end of while

    }
    static void mainMessage()
    {
    System.out.println("Welcome to TP DVD Rental Service");
    System.out.println(" ");
    System.out.println("-------DVD Rental System-------");
    System.out.println("--------------------------------");
    System.out.println("(1) Rent A DVD");
    System.out.println("(2) Exit");
    System.out.println("--------------------------------");
    System.out.println(" ");
    System.out.print("Please select your choice(1-2): ");
    }

    static void genre()
    {
    System.out.println(" ");
    System.out.println("**DVD Genre Selections**");
    System.out.println("------------------------");
    System.out.println("(1) Horror");
    System.out.println("(2) Love Stories");
    System.out.println("(3) Thrrillers");
    System.out.println("------------------------");
    System.out.print("Please select a category(1-3): ");
    }

    static void horror()
    {
    System.out.println(" ");
    System.out.println("Horror Movie Selections");
    System.out.println("-----------------------");
    System.out.println("(1) Drag Me To Hell");
    System.out.println("(2) Paranormal Activity");
    System.out.println("(3) Shutter");
    System.out.println("(4) Back to Main Menu");
    System.out.println("-----------------------");
    System.out.print("Please select desired movie(1-3): ");
    }

    static void love()
    {
    System.out.println(" ");
    System.out.println("Love Stories Selections");
    System.out.println("-----------------------");
    System.out.println("(1) P.S I Love You");
    System.out.println("(2) 500 Days Of Summer");
    System.out.println("(3) The Notebook");
    System.out.println("(4) Back to Main Menu");
    System.out.println("------------------------");
    System.out.print("Please select desired movie(1-3): ");
    }

    static void thriller()
    {
    System.out.println(" ");
    System.out.println("Thriller Selection");
    System.out.println("--------------------------------");
    System.out.println("(1) 2012");
    System.out.println("(2) The Day After Tomorrow");
    System.out.println("(3) Gamer");
    System.out.println("(4) Back to Main Menu");
    System.out.println("--------------------------------");
    System.out.print("Please select desired movie(1-3): ");
    }

    static void ok()
    {
    System.out.println("****************************** **********");
    System.out.println("* Your dvd booking(s) is/are confirmed *");
    System.out.println("****************************** **********");
    }

    static void defInOp()
    {
    System.out.println("Please re-select your booking.");
    System.out.println(" ");
    System.out.println("**DVD Genre Selections**");
    System.out.println("------------------------");
    System.out.println("(1) Horror");
    System.out.println("(2) Love Stories");
    System.out.println("(3) Thrrillers");
    System.out.println("------------------------");
    System.out.print("Please select a category(1-3): ");
    }
    }
    1621928_10202382619462155_934817616_n.jpg1656124_10202382619622159_362448811_n.jpg


  2. #2
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: Dvd Rental Program help?

    Please can you post the code in correct format for understanding?

    Now, what is the problem you are facing. We dont find a question.
    Thanks and regards,
    Sambit Swain

  3. The Following User Says Thank You to Sambit For This Useful Post:

    its2late2say (February 6th, 2014)

  4. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Dvd Rental Program help?

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

  5. #4
    Junior Member
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Dvd Rental Program help?

    Sorry, I've rearranged the codes. I could not make the part where I have to choose the number of days to rent work. I tried to put in -1 and the system allows it. But when I add another while loop, the system just keeps repeating the same thing until i enter a 0. And the part where I choose to redo my options. It has an extra line above what I want to show and i cant find the problem.






    import java.text.DecimalFormat;
    import java.util.Scanner;


    public class DVD_Rental_Program {

    //================================================== ============
    static Scanner input=new Scanner(System.in).useDelimiter("\r\n");
    static DecimalFormat fmt = new DecimalFormat("0.00");
    //================================================== ============
    static boolean ask = true;
    static int choice;
    static int confirm = 0;
    //================================================== ============
    static int[] days = new int[20];
    static int[] drag = new int[20];
    static int index =0;
    static String[] title = new String[20];
    //================================================== ============
    public static void main(String[] args) {

    int target;
    //Main Menu
    while(ask){
    mainMenu();

    switch(choice)
    {
    case 1:
    selectionMenu();
    choice =input.nextInt();
    if (choice >3)
    {
    System.out.println ("Please Reselect.");
    }
    if(choice == 1)
    {
    System.out.println("Horror Movie Selection");
    System.out.println("----------------------");
    System.out.println("(1)DRAG ME TO HELL");
    System.out.println("(2)PARANORMAL ACTIVITY");
    System.out.println("(3)SHUTTER");
    System.out.println("(4)Back to Main Menu");
    System.out.print("Please select desired movie(1-3) :");
    target = input.nextInt();
    horrorType(target);
    }
    else if(choice == 2)
    {
    System.out.println("Love Movie Selection");
    System.out.println("--------------------");
    System.out.println("(1)P/S I LOVE YOU");
    System.out.println("(2)500 DAYS OF SUMMER");
    System.out.println("(3)THE NOTEBOOK");
    System.out.println("(4)Back to Main Menu");
    System.out.print("Please select desired movie(1-3) :");
    target = input.nextInt();
    loveStories(target);
    }
    else if (choice == 3)
    {
    System.out.println("Thriller Movie Selection");
    System.out.println("------------------------");
    System.out.println("(1)2012");
    System.out.println("(2)THE DAY AFTER TOMORROW");
    System.out.println("(3)GAMER");
    System.out.println("(4)Back to Main Menu");
    System.out.print("Please select desired movie(1-3) :");
    target = input.nextInt();
    thriller(target);
    }

    break;

    case 2 : ask = false;
    System.out.println("You have rented the following DVD title<s> :");
    System.out.println("============================== =================");
    for(int counter = 0; counter < confirm ; counter++)
    {
    System.out.println("DVD Titles:" +title[counter]+ " Rented for " +days[counter]+ " days<s>." );
    System.out.println("Payment of S$" +fmt.format(drag[counter])+ " is approved" );
    System.out.println("============================== ===============================================" );
    }
    System.out.println("Thank you for using TP DVD Rental System");
    break;

    default : System.out.println("Please enter a valid choice");
    }

    }


    }

    static void mainMenu()
    {
    System.out.println("Welcome to TP DVD Rental Service\n");
    System.out.println("---DVD RENTAL SYSTEM---");
    System.out.println("-----------------------");
    System.out.println("(1) Rent a DVD");
    System.out.println("(2) Exit");
    System.out.println("-----------------------");
    System.out.print("Please select your choice(1-2): ");
    choice = input.nextInt();
    }


    static void selectionMenu()
    {
    System.out.println("**DVD GENRE SELECTION**");
    System.out.println("-----------------------");
    System.out.println("(1) Horror");
    System.out.println("(2) Love stories");
    System.out.println("(3) Thrillers");
    System.out.print("Please select a category(1-3): ");
    }
    static void horrorType(int horrorChoice)
    {
    int option = 0;
    switch(horrorChoice)
    {
    case 1:
    while(option !=1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: Drag Me To Hell");
    System.out.println("Length Price Per Day");
    System.out.println("90min S$4");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();

    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();

    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();


    }
    //Calculation
    drag[index]=days[index]*4; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: Drag Me To Hell");
    System.out.println("Length: 90 minutes");
    System.out.println("Movie released dare:August 2009");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$4");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();
    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<Drag Me To Hell>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;

    if (option ==2)
    mainMenu();
    if (option > 9)
    System.out.println("Please enter a valid choice");
    }
    }
    case 2:while(option != 1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: Paranormal Activity");
    System.out.println("Length Price Per Day");
    System.out.println("105min S$5");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();
    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();

    }
    //Calculation
    drag[index]=days[index]*5; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: Paranormal Activity");
    System.out.println("Length: 105 minutes");
    System.out.println("Movie released dare:October 2009");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$5");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();
    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<Paranormal Activity>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;
    if (option ==2)
    mainMenu();
    if (option > 9)
    System.out.println("Please enter a valid choice");
    }
    }
    case 3:while(option != 1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: Shutter");
    System.out.println("Length Price Per Day");
    System.out.println("95min S$3");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();
    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();


    }
    //Calculation
    drag[index]=days[index]*3; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: Shutter");
    System.out.println("Length: 95 minutes");
    System.out.println("Movie released dare:June 2006");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$3");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();

    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<Shutter>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;


    if (option ==2)
    mainMenu();

    if (option > 9)
    System.out.println("Please enter a valid choice");
    }


    }//end of switch
    }//end of while
    }



    static void loveStories(int loveType)
    {
    int option = 0;
    switch(loveType)
    {
    case 1:while(option != 1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: P.S I Love You");
    System.out.println("Length Price Per Day");
    System.out.println("120min S$4");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();
    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    }
    //Calculation
    drag[index]=days[index]*4; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: P.S I Love You");
    System.out.println("Length: 120 minutes");
    System.out.println("Movie released dare:Feburary 2009");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$4");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();
    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<P.S I Love You>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;
    if (option ==2)
    mainMenu();
    if (option > 9)
    System.out.println("Please enter a valid choice");
    }
    }
    case 2:while(option != 1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: 500 Days Of Summer");
    System.out.println("Length Price Per Day");
    System.out.println("105min S$5");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();
    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    }
    //Calculation
    drag[index]=days[index]*5; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: 500 Days Of Summer");
    System.out.println("Length: 105 minutes");
    System.out.println("Movie released dare:September 2009");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$5");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();
    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<500 Days Of Summer>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;
    if (option ==2)
    mainMenu();
    if (option > 9)
    System.out.println("Please enter a valid choice");
    }
    }
    case 3:while(option != 1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: The Notebook");
    System.out.println("Length Price Per Day");
    System.out.println("95min S$3");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();
    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    }
    //Calculation
    drag[index]=days[index]*3; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: The Notebook");
    System.out.println("Length: 95 minutes");
    System.out.println("Movie released dare:April 2005");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$3");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();

    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<The Notebook>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;
    if (option ==2)
    mainMenu();
    if (option > 9)
    System.out.println("Please enter a valid choice");
    }


    }//end of switch
    }
    }
    static void thriller(int thrillType)
    {
    int option = 0;
    switch(thrillType)
    {
    case 1:while(option != 1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: 2012");
    System.out.println("Length Price Per Day");
    System.out.println("150min S$5");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();
    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    }
    //Calculation
    drag[index]=days[index]*5; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: 2012");
    System.out.println("Length: 150 minutes");
    System.out.println("Movie released dare:November 2009");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$5");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();
    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<2012>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;
    if (option ==2)
    mainMenu();
    if (option > 9)
    System.out.println("Please enter a valid choice");
    }
    }
    case 2:while(option != 1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: The Day After Tomorrow");
    System.out.println("Length Price Per Day");
    System.out.println("125min S$4");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();
    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    }
    //Calculation
    drag[index]=days[index]*4; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: The Day After Tomorrow");
    System.out.println("Length: 125 minutes");
    System.out.println("Movie released dare:March 2007");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$4");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();
    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<The Day After Tomorrow>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;
    if (option ==2)
    mainMenu();

    if (option > 9)
    System.out.println("Please enter a valid choice");
    }
    }
    case 3:while(option != 1){
    System.out.println("****************************** ********");
    System.out.println("Desired Movie: Gamer");
    System.out.println("Length Price Per Day");
    System.out.println("90min S$5");
    System.out.print("please select desired days to rent(1-9): ");
    days[index] = input.nextInt();
    while(days[index] < 1 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    while(days[index] > 9 ){
    System.out.print("Please enter number of days <1-9> only :");
    days[index] = input.nextInt();
    }
    //Calculation
    drag[index]=days[index]*3; //total cost
    //Booking information
    System.out.println("Booking information");
    System.out.println("****************************** ********");
    System.out.println("Title: Gamer");
    System.out.println("Length: 90 minutes");
    System.out.println("Movie released dare:September 2009");
    System.out.println("Number of days rented: "+days[index]);
    System.out.println("Rental fee per day:$5");
    System.out.println("Total: "+fmt.format(drag[index]));
    System.out.println("****************************** ********\n");
    System.out.println("(1)Confirm");
    System.out.println("(2)Redo");
    System.out.print("Please select your choice(1-2): ");
    option=input.nextInt();

    if (option == 1)

    System.out.println("****************************** ********");
    System.out.println("*Your dvd booking(s) is/are confirmed*");
    System.out.println("****************************** ********");
    title[index] = "<Gamer>";
    confirm ++;//increase confirm by one so that when doing forward loop, it will show how many confirmations are done
    index ++;
    if (option ==2)
    mainMenu();

    if (option > 9)
    System.out.println("Please enter a valid choice");
    }


    }//end of switch
    }
    }



    }

  6. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Dvd Rental Program help?

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Dvd Rental Program help?

    You need to post your code correctly, or you won't get help. I gave you a link to a "how to," Norm gave you simple instructions. Please take action and post your code correctly. Fix what you've already posted using the "Edit Post" button at the bottom of the post.

Similar Threads

  1. Working on a Car Rental Program and need to finish by Tonight!!
    By alexsport93 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 13th, 2012, 11:08 PM
  2. Replies: 1
    Last Post: July 8th, 2012, 10:23 AM
  3. Java program to open and close computer CD/DVD drive
    By JavaPF in forum Java Programming Tutorials
    Replies: 0
    Last Post: January 28th, 2009, 12:04 PM
  4. Java program to open and close computer CD/DVD drive
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: January 28th, 2009, 12:04 PM

Tags for this Thread