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




Have Programming Question? Ask it here!
 
 
 


syed mohammed khalid
cp and sp
1 Answer(s)      3 years and a month 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
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
Singleton Design Pattern
;);   SingletonPattern sp=new SingletonPattern();   ...; sp=new SingletonPattern();   System.out.println("
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
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
java - Java Beginners
JComboBox combo; public MainClass() { Container cp = new Box(BoxLayout.X_AXIS); setContentPane(cp); JPanel firstPanel = new JPanel(); combo
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
Processing stored procedure in MySQL - SQL
); inv_name10:=var_rec.inv_code(10); end loop; end; in this SP.. i am
JTable - Java Beginners
tp; JPanel p; JButton showbutton; JScrollPane sp; jsk() { f=new...); showbutton=new JButton("Show Records"); sp= new JScrollPane(); sl= new..., columnNames); sp=new JScrollPane(table); p.add(sp); sl.putConstraint
Am i convetrting the code right ? - Java Beginners
Am i convetrting the code right ?  C# private void button_Click(object sender, EventArgs e){ SerialPort sp = new SerialPort(SerialPort.GetPortNames()[0], 9600, Parity.None, 8, StopBits.One); String[] str
creating class and methods - Java Beginners
quantity; public Computer(String n,int s,int sp,String m,double p,int q){ name=n; size=s; speed=sp; make=m; price=p; quantity=q; } public String
Java Program - Java Beginners
; public Computer(String n,int s,int sp,String m,double p,int q){ name=n; size=s; speed=sp; make=m; price=p; quantity=q; } public String getName(){ return
JTable values are not gettiing properly
details JTable table=null; JScrollPane js=null; Container cp=null; JPanel p=null...=null; public sd25()throws Exception { cp=getContentPane(); cp.setLayout(null
PHP Date and Time
DateTime DateTime { /* Constants */ const string DateTime::ATOM = Y-m-d\TH:i:sP...-m-d\TH:i:sP ; const string DateTime::RSS = D, d M Y H:i:s O ; const string DateTime::W3C = Y-m-d\TH:i:sP ; /* Methods */ public DateTime add ( string
Java Project - Java Beginners
; public Computer(String n,int s,int sp,String m,double p,int q){ name=n; size=s; speed=sp; make=m; price=p; quantity=q; } public String getName(){ return
computer management - Java Beginners
; static int quantity; public Computer(String n,int s,int sp,String m,double p,int q){ name=n; size=s; speed=sp; make=m; price=p; quantity=q; } public
computer configuration - Java Beginners
sp,String m,double p,double q){ this.name=n; this.size=s; this.speed=sp; this.make=m; this.price=p; this.quantity=q; } public void valid(){ if((price
java - Java Beginners
; JScrollPane sp; GridBagLayout gbl; GridBagConstraints gbc; //constructor...; JPanel p; JLabel l; JTextField tf; JButton btn; JScrollPane sp
jTable data problem
=new JPanel(); JScrollPane sp=new JScrollPane(table); panel.add(sp
java inheritance
ArrayList<employees>(); sales_person sp = new sales_person ("john", 33444); es.add(sp); sales_agent sa = new sales_agent("adrian", 44444
SHOWING ERROR CODE 1064 WHILE TRYING TO EXECUTE PROCEDURE
SHOWING ERROR CODE 1064 WHILE TRYING TO EXECUTE PROCEDURE  I AM TRYING A SP BUT IT IS NOT SAVING AND WORKING.DOES THE STORED PROCEDURE WORK PARTLY? BELOW IS MY QUERY DELIMITER$$ DROP PROCEDURE IF EXISTS `test_query`.`updt_cls
about swing - Java Beginners
; System.out.println("num:" + num); Container cp = getContentPane
java button - Java Beginners
); } }); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(cb1
accessing data from a json file writing javascript or using jQuery
'}, {N:'nwItem44',O:'Atlas'} ], 'grades': [ {U:'http://www.donson.net/cp
Exception when opening a excel file in JFrame
_ON_CLOSE); Container cp = frame.getContentPane(); cp.setLayout
 

 

 

DMCA.com