View Single Post
  #1 (permalink)  
Old 01-27-2008, 06:58 AM
Deon's Avatar
Deon Deon is offline
Member
 
Join Date: Jan 2008
Posts: 12
Deon is on a distinguished road
Need help on this question
Hello guys,

I need help again~ for this project question . I have done half way and got stuck

here is the output i must get:



i have make 2 class file and 1 driver file

The class file are call "Customer" and "bookDetail"
and 1 driver file is call "BookStore"

i can't slove the problem in "BookStore" and the code is incomplete

"Customer":
PHP Code:
public class Customer{

      
//attributes
      
private String Name;
      private 
String Address;
      private 
int Contact;

      
//three-argument constructor
      
public Customer (String newNameString newAddressint newContact){
                         
Name newName;
                         
Address newAddress;
                         
Contact newContact;
      }
      
      
      
     public 
String getName(){
          return 
Name;
     
     }

     public 
String getAddress(){
          return 
Address;

    }

    public 
int getContact(){
         return 
Contact;

    }





"bookDetail:"

PHP Code:
public class bookDetail
{
    
String Cata "";
    
String Title "";
    
String Author "";
    
int Cost 0;

    public 
bookDetail()
    {
        
Cata "";
        
Title "";
        
Author "";
        
Cost 0;
    }

    public 
void update(String xCataString xTitleString xAuthorint xCost)
    {
        
Cata xCata;
        
Title xTitle;
        
Author xAuthor;
        
Cost xCost;
    }

    public 
void display()
    {
        
System.out.println("Catalogry: " Cata);
        
System.out.println("Title: " Title);
        
System.out.println("Author: " Author);
        
System.out.println("Cost : " Cost);
    }

    
    public 
String getCata()
    {
        return 
Cata;
    }
    
    public 
String getTitle()
    {
        return 
Title;
    }
    
    public 
String getAuthor()
    {
        return 
Author;
    }

    public 
int getCost()
    {
        return 
Cost;
    }    




and finally my driver file

"BookStore:"

PHP Code:
import java.util.Scanner;

public class 
BookStore
{
    public static 
void main(String args[])
    {
        
String nName,newAddress,receipt,customer,choice,movies,cont="N";
    
        
int Cost,custTel;
    
        
//int BookCata = 0;
        
String BookTitle "";
        
//string BookAuthor = "";
        //double BookCost = 0;
        
        
String YesAndNo "";
        
Scanner in= new Scanner(System.in);

        
        
int NumOfBook 15;
        
bookDetail[] book = new bookDetail[NumOfBook];

        for(
int i 0NumOfBooki++)
        {

            
book[i] = new bookDetail();

        }

        
book[0].update("0001""The Secret""Rhonda Byrne"10);
        
book[1].update("0002""Secrets of Self-Made Millionaires""Adam Khoo"10);
        
book[2].update("0003""An Illustrated Biography of the World’s Most Successful Investor""Warren Buffet"15);    
        
book[3].update("0004""How good do we have to be ?""Harold Kushnere"8);
        
book[4].update("0005""Half a Life""V. S. Naipaul"5);
        
book[5].update("0006""Subconscious Mind""Murphy McMahan"6);
        
book[6].update("0007""The Road Less Travelled""M. Scott Peck"5);
        
book[7].update("0008""Stop the insanity!""Susan Powter"5);
        
book[8].update("0009""Business As Usual""Anita Roddick"6);
        
book[9].update("0010""Rich Kid, Smart Kid""Robert Kiyosaki"6)    ;
        
book[10].update("0011""Secrets of the Millionaire Mind""Harv Eker"10);
        
book[11].update("0012""Where have all the leaders gone?""Lee Iacocca"15);
        
book[12].update("0013""If success is a game, these are the rules""Cherie Carter"8);
        
book[13].update("0014""Think Big""Donald Trump"15);
        
book[14].update("0015""Blink""Malcolm Gladwell"10);

        
        
        
System.out.print("Enter the title of book: ");
        
BookTitle in.nextLine();
        
BookTitle BookTitle.toUpperCase();
        
        
String CheckBookTitle "";
        
        
int index 0;

        for(
int i 0NumOfBooki++)
        {
            
CheckBookTitle book[i].getTitle();
            
CheckBookTitle CheckBookTitle.toUpperCase();
            
            if(
BookTitle.compareTo(CheckBookTitle) == 0)
            {
                
System.out.println(BookTitle.compareTo(CheckBookTitle));
                
                
index i;
                
System.out.println("Book title: " BookTitle +" found");

                
System.out.println("Detail for the book title " book[i].getTitle());
                
System.out.println("Author: " book[i].getAuthor());
                
System.out.println("Catalogue " book[i].getCata());
                
System.out.println("Cost: $" book[i].getCost());
                
System.out.println("");
                
System.out.println(book[i].getTitle() + " Is available");
                
System.out.println("Cost to rent is " book[i].getCost());

                
System.out.println("Proceed to rent? (Y/N) :");
                
choicein.nextLine();

            if(
choice.equalsIgnoreCase("Y"))
            {
                
//customer particulars
                       
System.out.print("Please enter customer's name: ");
                       
nName=in.nextLine();
           
                       
System.out.print("Please enter customer's address: ");
                       
newAddress =in.nextLine();
           
                       
System.out.print("Please enter customer's telephone number: ");
                       
custTelin.nextInt(); 
           
                
                        
Customer aCust = new Customer(nName,newAddress,custTel);
                
                
                        
customer="\nPrinting out receipt for " aCust.getName()+ "...""\n" 
                                 
"Address: " aCust.getAddress() +"\n\n"
                             
                        
receipt="Renting out " BookTitle " for " " $ "book[i].getCost()  +"\n"+"\n"+
                             
"\nThank You For renting our Books please come again" "\n\nServing next customer.......";
                
                        
System.out.println(customer receipt );
                
                    }            
            }
        }
        
        if(
choice.equalsIgnoreCase(""))
            {
                
System.out.print("??");
            }        
            
        
            if(
choice.equalsIgnoreCase("N"))
            {
                
System.out.println("Serving next customer....");
                
cont=in.nextLine();
            }

        while(
cont.equalsIgnoreCase("Y"));
        
System.out.println("GoodBye!! ");
               
System.exit(0);

            

        } 
//main
//class 
__________________
I LOVE JAVA!

Last edited by Deon : 01-27-2008 at 10:21 AM.
Reply With Quote
Sponsored Links