Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

cp and sp

Ads

 
 

Share on Google+Share on Google+

syed mohammed khalid
cp and sp
1 Answer(s)      6 years 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

Ads
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();
    }
}

Ads









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
Version of com.immibytes>sp-utils dependency
List of Version of com.immibytes>sp-utils dependency
Advertisements
Version of com.appslandia>appslandia-common-cp dependency
List of Version of com.appslandia>appslandia-common-cp dependency
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
Maven Dependency sp-utils >> 1.0.0-RELEASE
You should include the dependency code given in this page to add Maven Dependency of com.immibytes >> sp-utils version1.0.0-RELEASE in your project
Maven Dependency appslandia-common-cp >> 1.0
You should include the dependency code given in this page to add Maven Dependency of com.appslandia >> appslandia-common-cp version1.0 in your project
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
java - Java Beginners
Container cp; static Random random = new Random(); public...(this); cp = getContentPane(); cp.setLayout(new FlowLayout
How to create file from input values in Jframe ?
cp=new JPanel(); text1=new JTextArea(); cp.add(text1); frame.add(cp
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
source code program - Java Beginners
! class temp { public static void main(String cp[]) { int x=0,y
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
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
java-help - Java Beginners
; JTextArea ta=null; JScrollPane sp=null; File f=null; FileOutputStream...=ca; ta=new JTextArea(); sp=new JScrollPane(ta); clustersOutput
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
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
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
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
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 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
What is Stored Procedure?
ensure the integrity of the database. e.g. sphelpdb, sprenamedb, sp_depends etc
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
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
servlet - JSP-Servlet
("         &nb sp;   
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