Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


syed mohammed khalid
cp and sp
1 Answer(s)      3 years and 3 months ago
Posted in : IDE Questions


design a gui application to accept the cost price and selling price from the user in two textfields and then calculate the profit or loss occured


Advertisement
View Answers

August 2, 2011 at 5:39 PM


import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

class  FindProfitOrLoss{
    public static void main(String[] args){
    Frame f=new Frame();
    Label label1=new Label("Enter CP: ");
    Label label2=new Label("Enter SP: ");
    final TextField text1=new TextField(20);
    final TextField text2=new TextField(20);
    Button b=new Button("Find");
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        int cp=Integer.parseInt(text1.getText());
        int sp=Integer.parseInt(text2.getText());
        if(cp>sp){
            int loss=cp-sp;
            JOptionPane.showMessageDialog(null,"There is a loss of "+loss+" rupees");
        }
        if(sp>cp){
            int profit=sp-cp;
            JOptionPane.showMessageDialog(null,"There is a profit of "+profit+" rupees");
        }
        }
        });
        Panel p=new Panel(new GridLayout(3,2));
        p.add(label1);
        p.add(text1);
        p.add(label2);
        p.add(text2);
        p.add(b);
        f.add(p);
        f.setVisible(true);
        f.pack();
    }
}


Related Tutorials/Questions & Answers:
cp and sp
cp and sp  design a gui application to accept the cost price and selling price from the user in two textfields and then calculate the profit or loss occured
WEBLOGIC8.1 SP 6 - JSP-Servlet
WEBLOGIC8.1 SP 6   SIR, I am new to jsp and weblogic8.1 and developing project on jsp use of oracle9i.My doubt is how to use RowSet and retrive the values using RowSet,displaying that in a text box based on the data
Advertisements
Draw Pie Chart
: g2.draw(new Line2D.Double(cp, cq, p, q)) The angle...++)         {             p = cp + (pie/2) * Math.cos(theta);             q = cq + (pie/2) * Math.sin(theta);             g2.draw(new Line2D.Double(cp, cq, p, q
running java with classpath in cygwin
running java with classpath in cygwin  The following command works in cmd.exe but failts in cygwin shell. java -cp .;oracle.jar;mysql.jar Executecmd query value; how should i alter the command to run in the bash shell?thanks
annotation error
. javac -cp JdbcProjam.java
Exception in thread
-cp D:\mail.jar SendMailTLSDFC.java above command is working properly. It creates... but when i am trying to run following command I am getting an error. java -cp D
How to Set Transperent Background Image to Jpanel - Java Beginners
); } }; area.setOpaque(false); JScrollPane sp = new JScrollPane( area ); frame.getContentPane().add( sp
How to create file from input values in Jframe ?
cp=new JPanel(); text1=new JTextArea(); cp.add(text1); frame.add(cp
java - Java Beginners
Container cp; static Random random = new Random(); public...(this); cp = getContentPane(); cp.setLayout(new FlowLayout
Get JTextField value from another class
; void form() { frame=new JFrame("test"); JPanel cp=new JPanel(); text1=new JTextField(10); cp.add(text1); frame.add(cp...=new JButton("Submit"); f=new JFrame("test"); JPanel cp
source code program - Java Beginners
! class temp { public static void main(String cp[]) { int x=0,y
coding problem in netbeans - Java Beginners
"); JPanel cp=new JPanel(); text1=new JTextField(10); cp.add(text1); frame.add(cp); frame.setSize(300,100); frame.setVisible(true); } } 2...=new JButton("Submit"); f=new JFrame("test"); JPanel cp=new JPanel(); cp.add
Can anybody help me with this simple MySql code
i run that: countryid bp sp country time 2 43 53 ind... a query should display me: countryid bp sp country time 2 43 53
java-help - Java Beginners
; JTextArea ta=null; JScrollPane sp=null; File f=null; FileOutputStream...=ca; ta=new JTextArea(); sp=new JScrollPane(ta); clustersOutput
java - Java Interview Questions
[]){ System.out.println("The output of two instance:"); SingletonPattern sp=new SingletonPattern(); System.out.println("First Instance: "+sp.getInstance()); sp=new
JTable - JDBC
[][] = {{"","","",""},{"","","",""},{"","","",""},{"","","",""}}; String col[] = {"Code","Name","Mobile","Email"}; JScrollPane sp... DefaultTableModel(data,col); tb=new JTable(model); sp=new JScrollPane(tb...; gbl.setConstraints(sp,gbc); p.add(sp); f.setVisible(true
JTable - Java Beginners
; JButton showbutton; JScrollPane sp; jsk() { f=new JFrame... JButton("Show Records"); sp= new JScrollPane(); sl= new SpringLayout...().getColumn(i); col.setPreferredWidth(1); } sp=new JScrollPane(table
array split string
++IFE:Y++AD:Y++IR:++MV:++CP:~ ~N:ERedemption++RGI:42++R:200++T:Purchase++IP:N...:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP
java swings - Java Beginners
=new JButton("Submit"); f=new JFrame("test"); JPanel cp=new JPanel(); cp.add...); f.setVisible(true); f.add(cp); } public void actionPerformed(ActionEvent ae) { m
JAVA Debug tool
JAVA Debug tool  Hi , I invoke the JDebugTool using the following command on MS DOS : "c:/Users/mkarapanahalli/Programfiles/Java/jdk1.7.0/bin/java" -cp "c:/Users/mkarapanahalli/Desktop/jdebugtool/jdebugtool.jar; c:Users
SQUANDER CRPTOGRAPHY
together in a pair, so where that happens, we shove in a Q, which won't confuse... letter at the end, we'd add on another Q to square it up. Now we take our first... corners are SP. So we put down SP for the first two letters of the coded message
SQUANDER CRPTOGRAPHY
together in a pair, so where that happens, we shove in a Q, which won't confuse... letter at the end, we'd add on another Q to square it up. Now we take our first... corners are SP. So we put down SP for the first two letters of the coded message
servlet - JSP-Servlet
("         &nb sp;   
arraylist not able to store large amount of data( over 1 lakh records) - Java Interview Questions
data is fetched through SP and database is on another server. Pls help me
JTable - Java Beginners
; JScrollPane sp; jsk() { f=new JFrame("Testing JSK SDMPL"); p=new..."); sp= new JScrollPane(); sl= new SpringLayout(); } void dis...(); JTable table = new JTable(data, columnNames); sp=new JScrollPane(table
What is Stored Procedure?
ensure the integrity of the database. e.g. sphelpdb, sprenamedb, sp_depends etc
Singleton Design Pattern
;);   SingletonPattern sp=new SingletonPattern();   ...; sp=new SingletonPattern();   System.out.println("
java main program
compOne, String compTwo) { int cp = 0; for (int i = 0; i < 4; i++) { if (compOne.charAt(i) == compTwo.charAt(i)) cp++; } return cp
Class names don't identify a class - Java Tutorials
FirstClass()); } } Compile the Test class as C:\>javac -cp .;directory1 Test.java Now run this program as C:\>java -cp .;directory1 Test..., The output of the above class is as, C:\>java -cp .;directory2
query
; Container cp=null; JPanel p=null; JLabel months3=null,date=null,ghba1c=null,per=null; JButton jb1=null; public table() { cp=getContentPane(); cp.setLayout(null
 

 

 

DMCA.com