<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import
java.text.DecimalFormat;
import java.util.Scanner;
public class BookBillSystem {
        public static void main(String[] args) {
                //create the Scanner instance for taking input from console
                Scanner scanner = new Scanner(System.in);
                //take input customer name
                System.out.print("Customer Name: ");
                String customerName = scanner.nextLine();
                //take input noOfBooks purchased
                System.out.print("No of books purchased: ");
                int noOfBooks = scanner.nextInt();
                //take input membership type
                System.out.print("Membership type (1 for Regular, 2 for Premium): ");
                int memberShipType = scanner.nextInt();
                //now do the processing
                //declarng constants
                final double REGULAR_BOOK_PRICE = 12.95;
                final double PREMIUM_BOOK_PRICE = 11.49;
                int effectiveNo;
                int freeBooks;
                double grossPrice;
                double totalPrice;
                double salesTax;


        memberShipType = JOptionPane.showConfirmDialog(null, "upgrade to 4.95?");
                    if (nResponse == JOptionPane.YES_OPTION) {
                      System.out.println("User wants to upgrade");} 
                    else if (nResponse == JOptionPane.NO_OPTION) {
              System.out.println("User does not want to upgrade.”"); } else {
    System.out.println("User cancelled.”"); } //end if to check user input      












                if (memberShipType==1){ //regular customer
                        if (noOfBooks<8)
                                freeBooks = 0;
                        else if(noOfBooks>=8 && noOfBooks<=12)
else
freeBooks = 1;
freeBooks = 2;
        effectiveNo = noOfBooks - freeBooks;
        grossPrice = effectiveNo * REGULAR_BOOK_PRICE;
        //calculating salestax @6.5%
        salesTax = grossPrice * .65;
        //calculating netPrice after adding tax
        totalPrice = grossPrice + salesTax;
}
else { //premium customer
        if (noOfBooks<6)
                freeBooks = 0;
        else if(noOfBooks>=6 && noOfBooks<=9)
                freeBooks = 1;
else
effectiveNo = noOfBooks - freeBooks;
freeBooks = 2;
                        //calculating totalPrice for premium member
                        grossPrice = effectiveNo * PREMIUM_BOOK_PRICE;
                        //calculating salestax @6.5%
                        salesTax = grossPrice * .65;
                        //calculating netPrice after adding tax
                        totalPrice = grossPrice + salesTax;
                }
                //print receipt
                System.out.println("-----------------gBooks Receipt------------------");
                System.out.println("--------A subsidiary of Grapefruit Company-------");
                System.out.println("-------------------------------------------------");
                System.out.println("Customer Name: " + customerName);
                if (memberShipType==1)
                        System.out.println("Membership type: \"Regular\"");
else
                        System.out.println("Membership type: \"Premium\"");
                System.out.println("Total no of books received: " + noOfBooks);
                System.out.println("Price of books before sales tax: $"+ new
DecimalFormat("0.00").format(grossPrice));
                System.out.println("Sales tax @6.5%: $"+ new
DecimalFormat("0.00").format(salesTax));
                System.out.println("Total amount due: $"+ new
DecimalFormat("0.00").format(totalPrice));
                System.out.println("-------------------------------------------------");
}
}
</pre></body></html>

i need help with line 28 - 33 how would i write the dialouge box in this for :

Use a Confirmation Dialog box to allow the user to upgrade their membership from Regular to Premium if he/she is currently a Regular member:
Title: Upgrade Membership
Message: Would you like to become a member for $4.95?
The Confirmation Dialog box should appear after you ask the user to enter their membership type. Based on what the user selects, the following message should be printed to the screen:
Yes: “Thank you. Your membership fee will be added to your receipt.”
No: “Thank you for your consideration.”
Cancel: “You may purchase a membership in the future.”
In addition, if the user chooses to upgrade their membership, they should be treated as a Premium customer and should also be charged a $4.95 membership fee.

i wrote this code i just dont know how to write the dialouge code

you wrote this code .... what is that html doing in there?

so, you need help with this ...

memberShipType = JOptionPane.showConfirmDialog(null, "upgrade to 4.95?");
                    if (nResponse == JOptionPane.YES_OPTION) {
                      System.out.println("User wants to upgrade");} 
                    else if (nResponse == JOptionPane.NO_OPTION) {

why do you compare nResponse, which is a variable that doesn't seem to exist, and why do you first read memberShipType using a Scanner, just so you can ignore that value and overwrite it using JOptionPane ?
1. you should compare memberShipType
2. the correct way according to naming conventions to write that is: membershipType (since membership is one word)

This article has been dead for over six months. Start a new discussion instead.