Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to display item name, code, quantity, price and grade

Posted By: Milind Mishra     Category: Artificial Intelligence     Views: 12356

Prolog program to display item name, code, quantity, price and grade.

Code for Prolog program to display item name, code, quantity, price and grade in Artificial Intelligence

database
    manufacture(string,integer,real,integer,char)

predicates
    
    getdetail
    readdetail
goal 
    clearwindow,
    getdetail,
    readdetail.
clauses

    getdetail:-    
        write("\nenter the name of item ="),
        readln(Itemname),
        write("\nenter the item code ="),
        readint(Itemcode),
        write("\nenter the quantity ="),
        readint(Itemqu),
        write("\nenter the price of item ="),
        readreal(Itemprice),
        write("\nenter the grade of item ="),
        readchar(Itemgrade),
        write(Itemgrade),
        char_int(Itemgrade,Val),
        Val >= 97,
        Val <=104,
        assertz(manufacture(Itemname,Itemcode,Itemprice,Itemqu,Itemgrade)),
        write("\nDo you want to continue(y/n)= "),
        readchar(Ans),
        write(Ans),
        Ans='y',
        getdetail.
    getdetail.

    readdetail:-                manufacture(Itemname,Itemcode,Itemprice,Itemqu,Itemgrade),
    retract(manufacture(Itemname,Itemcode,Itemprice,Itemqu,Itemgrade)),        
        write("\nItem Name = ",Itemname),nl,
    write("Item code = ",Itemcode),nl,
    write("Item quantity = ",Itemqu),nl,
    write("Item Price = ",Itemprice),nl,
    write("Item grade = ",Itemgrade),nl,
    fail.
    
    
    readdetail.                        
  
Share: 



Milind Mishra
Milind Mishra author of Prolog program to display item name, code, quantity, price and grade is from India.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!