Welcome to Dream.In.Code
Become a Java Expert!

Join 150,053 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,734 people online right now. Registration is fast and FREE... Join Now!




Mathematics sum

 
Reply to this topicStart new topic

Mathematics sum

prajayshetty
13 Jun, 2008 - 04:43 AM
Post #1

D.I.C Head
Group Icon

Joined: 27 Apr, 2007
Posts: 230



Thanked: 1 times
Dream Kudos: 25
My Contributions
The below code is for question

find q
if q= sinx+cos-e rasied to -y/
e raised to y+e raised to -y -2 cosx
where e =1 const

CODE


import java.util.*;
import java.lang.Math;


class calculation
{
    String len,len1;
    double x,x1,x2,x3,x4,x5,x6,y,y1,y2,result,result1,result2;
    final int e=1;
    void getdata()
    {
    Scanner in = new Scanner(System.in);
    try
    {
        System.out.println("Enter the value of x");
        len=in.nextLine();
        x = Double.valueOf(len);
        System.out.println("Enter the value of y");
        len1=in.nextLine();
        y=Double.valueOf(len1);
        
        
    }
    catch(Exception e)
    {
        System.out.println("Error input or output");
    }
    x1=Math.sin(x);
    x2=Math.cos(x);
    y1=Math.sin(y);
    y2=Math.cos(y);
    x3=Math.pow(e, y);
    x4=Math.pow(e, (-y));
    x5=x*x;
    x6=Math.cos(x5);
    result1=(x1+y1-x4);
    result2=(x3+x4-(2*x2));
    result=result1/result2;
    
    }
}
public class Sum  {
    
    public static void main(String args[])
    {
     calculation c = new calculation();
     c.getdata();
    System.out.println("The answer is "+ c.result1);
    System.out.println("The answer is "+c.result2);
    System.out.println("The answer is final result "+c.result);
    
    }
}



if user does some mathematical error then how to i find out
and give him the info

User is offlineProfile CardPM
+Quote Post

gl3thr0
RE: Mathematics Sum
13 Jun, 2008 - 05:03 AM
Post #2

D.I.C Head
**

Joined: 27 Oct, 2007
Posts: 209



Thanked: 3 times
My Contributions
what do you mean by "mathematical error"? do you mean he enters a letter instead of a number?
because it does not look like the user ever does math..
User is offlineProfile CardPM
+Quote Post

prajayshetty
RE: Mathematics Sum
13 Jun, 2008 - 07:44 AM
Post #3

D.I.C Head
Group Icon

Joined: 27 Apr, 2007
Posts: 230



Thanked: 1 times
Dream Kudos: 25
My Contributions
QUOTE(gl3thr0 @ 13 Jun, 2008 - 06:03 AM) *

what do you mean by "mathematical error"? do you mean he enters a letter instead of a number?
because it does not look like the user ever does math..


ya if he does enter then what to do
User is offlineProfile CardPM
+Quote Post

pbl
RE: Mathematics Sum
13 Jun, 2008 - 01:33 PM
Post #4

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
BYW I removed your useless len and len1

CODE

    Scanner in = new Scanner(System.in);
    boolean error = true;
    
    while(error) {
       try
       {
           System.out.println("Enter the value of x");
           x = in.nextDouble();
           System.out.println("Enter the value of y");
           y = in.nextDouble();
           error = false;
       }
       catch(Exception e)
       {
           System.out.println("Error input or output");
       }
    }

User is online!Profile CardPM
+Quote Post

prajayshetty
RE: Mathematics Sum
13 Jun, 2008 - 07:26 PM
Post #5

D.I.C Head
Group Icon

Joined: 27 Apr, 2007
Posts: 230



Thanked: 1 times
Dream Kudos: 25
My Contributions
[quote name='pbl' date='13 Jun, 2008 - 02:33 PM' post='369472']
BYW I removed your useless len and len1

CODE

    Scanner in = new Scanner(System.in);
    boolean error = true;
    
    while(error) {
       try
       {
           System.out.println("Enter the value of x");
           x = in.nextDouble();
           System.out.println("Enter the value of y");
           y = in.nextDouble();
           error = false;
       }
       catch(Exception e)
       {
           System.out.println("Error input or output");
       }
    }

[/quote
well then len and len1 is not required then


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:23PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month