Starting out with Java: From control structures through objects, 1e
Complete the programming challenge Chapter 13 #4 Make sure that you CREATE A MENU SYSTEM. The menu should have sub-menus for plans, phones, options, and a file menu that allows the user to exit the GUI. The total cost of the plan should be displayed and updated as the user makes menu choices.
package GUI;
import java.awt.event.*;
import javax.swing.*;
public class Menu extends JFrame implements ActionListener
{
JMenu plansM, phonesM, optionsM, fileM;
JMenuBar jmb;
JMenuItem exitMI, showPhoneMI, displayCostMI;
JCheckBoxMenuItem visitPuriCMI, visitKonarkCMI, visitParkCMI;
Menu()
{
jmb = new JMenuBar();
plansM = new JMenu("Plan");
phonesM = new JMenu("Phone");
optionsM = new JMenu("Options");
fileM = new JMenu("File");
exitMI = new JMenuItem("EXIT");
visitPuriCMI = new JCheckBoxMenuItem("Visit Puri");
visitKonarkCMI = new JCheckBoxMenuItem("Visit Konark");
visitParkCMI = new JCheckBoxMenuItem("Visit Park");
showPhoneMI = new JMenuItem("Visit Contact");
displayCostMI = new JMenuItem("Total Cost");
setJMenuBar(jmb);
jmb.add(fileM);
jmb.add(plansM);
jmb.add(phonesM);
jmb.add(optionsM);
fileM.add(exitMI);
plansM.add(visitPuriCMI);
plansM.add(visitKonarkCMI);
plansM.add(visitParkCMI);
phonesM.add(showPhoneMI);
optionsM.add(displayCostMI);
exitMI.addActionListener(this);
visitPuriCMI.addActionListener(this);
visitKonarkCMI.addActionListener(this);
visitParkCMI.addActionListener(this);
showPhoneMI.addActionListener(this);
displayCostMI.addActionListener(this);
// Sets the size of the frame
setSize(300, 300);
// Sets the location to center of the window
setLocationRelativeTo(null);
// Sets the visible to true
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
double amount = 0.0;
int flag = 0;
if(exitMI.isSelected())
System.exit(0);
if(visitPuriCMI.isSelected() && visitKonarkCMI.isSelected() &&
visitParkCMI.isSelected())
{
JOptionPane.showMessageDialog(null, "Visit Puri Cost $ " + 500 +
"\n Visit Konark Cost $ " + 1000 + "Visit Park Cost $ " + 200);
amount += 1700;
}
else if(visitPuriCMI.isSelected() && visitKonarkCMI.isSelected())
{
JOptionPane.showMessageDialog(null, "Visit Puri Cost $ " + 500 +
"\n Visit Konark Cost $ " + 1000);
amount += 1500;
}
else if(visitPuriCMI.isSelected() && visitParkCMI.isSelected())
{
JOptionPane.showMessageDialog(null, "Visit Puri Cost $ " + 500 +
"\n Visit Park Cost $ " + 200);
amount += 700;
}
else if(visitKonarkCMI.isSelected() && visitParkCMI.isSelected())
{
JOptionPane.showMessageDialog(null, "Visit Konark Cost $ " + 1000 +
"\n Visit Park Cost $ " + 200);
amount += 1200;
}
else if(visitPuriCMI.isSelected())
{
JOptionPane.showMessageDialog(null, "Visit Puri Cost $ " + 500);
amount += 500;
}
else if(visitKonarkCMI.isSelected())
{
JOptionPane.showMessageDialog(null, "Visit Konark Cost $ " + 1000);
amount += 1000;
}
else if(visitParkCMI.isSelected())
{
JOptionPane.showMessageDialog(null, "Visit Park Cost $ " + 200);
amount += 200;
}
if(displayCostMI.isSelected())
JOptionPane.showMessageDialog(null, "Your Traveling Cost $" + amount);
if(showPhoneMI.isSelected())
{
JOptionPane.showMessageDialog(null, "In Contact");
if(visitPuriCMI.isSelected() && visitKonarkCMI.isSelected() &&
visitParkCMI.isSelected())
JOptionPane.showMessageDialog(null, "Visit Puri Mobile: 9440999477" +
"\n Visit Konark Mobile: 9880911175" +
"\n Visit Park Mobile: 9666111444");
else if(visitPuriCMI.isSelected() && visitKonarkCMI.isSelected())
JOptionPane.showMessageDialog(null, "Visit Puri Mobile: 9440999477" +
"\n Visit Konark Mobile: 9880911175");
else if(visitPuriCMI.isSelected() && visitParkCMI.isSelected())
JOptionPane.showMessageDialog(null, "Visit Puri Mobile: 9440999477" +
"\n Visit Park Mobile: 9666111444");
else if(visitKonarkCMI.isSelected() && visitParkCMI.isSelected())
JOptionPane.showMessageDialog(null, "Visit Konark Mobile: 9880911175" +
"\n Visit Park Mobile: 9666111444");
else if(visitPuriCMI.isSelected())
JOptionPane.showMessageDialog(null, "Visit Puri Mobile: 9440999477");
else if(visitKonarkCMI.isSelected())
JOptionPane.showMessageDialog(null, "Visit Konark Mobile: 9880911175");
else if(visitParkCMI.isSelected())
JOptionPane.showMessageDialog(null, "Visit Park Mobile: 9666111444");
}
}
// main method definition
public static void main(String[] pyari)
{
// Calls the constructor using anonymous object
new Menu();
}// End of main method
}// End of driver class
Starting out with Java: From control structures through objects, 1e Complete the programming challenge Chapter 13...
Will someone please post the solution to Starting out with C++ from control structures through objects 8th edition chapter 7 programming challenge # 16.
Starting out with C++ From Control Structures through Objects 8th Edition Chapter 7 Programming Challenges Number 5
starting out with >>> C++ EARLY OBJECTS - Chapter 15 Programming Challenge #7 Write a program that creates two rectangular shapes and then animates them. The two shapes should start on opposite ends of the screen and then move toward each other. When they meet in the middle of the screen, each shape reverses courses and moves toward the edge of the screen. The two shapes keep oscillating and bouncing off of each other in the middle of the screen....
Starting out with C++ Early Objects solution 8th edition, chapter 8 programming challenge 11... line case 2:cc.properWords(s) is giving me a build error... build error states "properWords" is not a char converter. How do I fix this?
Java Programming Exercise 9-7 In the exercises in Chapter 6, you created a class named Purchase. Each Purchase contains an invoice number, amount of sale, amount of sales tax, and several methods. Add get methods for the invoice number and sale amount fields so their values can be used in comparisons. Next, write a program that declares an array of five Purchase objects and prompt a user for their values. Then, in a loop that continues until a user inputs...
Chapter 14 starting out with c++ from control structures through objects Feet Inches Modification Modify the FeetInches class discussed in this chapter so it overloads the following operators: <= >= != Demonstrate the class's capabilities in a simple program.
the code is in visual basic 376 Chapter 6 Loop Structures Case Programming Assignments con Most Rainfall in the USA USE CASE DEFINITION e Windows application opens with the heading "Most Rainfall in US - Kauai," a ListBox object that displays the monthly rainfall amounts, an i amounts in inches mage, and a Button object that allows the user to begin entering their rainfall 2. A menu bar displays the File menu, which has two menu items: Clear and Exit....
Starting Out with C++ From Control Structures through Objects, Tony Gaddis, 9th edition, ISBN 978- 0134498379. Number guessing game Seed the random numbers. Have the computer randomly select a number between 1 and 10. Loop: Ask the user for a number between 1 and 10. Validate the user's entry. If invalid, repeat the loop. Compare the user's guess to the computer's and show the results: too low, too high, or matching
Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required. Project Requirements Develop a text...
I have to use java programs using netbeans. this course is introduction to java programming so i have to write it in a simple way using till chapter 6 (arrays) you can use (loops , methods , arrays) You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...