hi guyz and GiRlzz (F) ;;

how R u ?

plllz I need 4 helpping from u !!

I've a Q in Java ,, I'm trying to write it in jGRASP but I can't :s

plllllzzz hellp me before next Suterday ;s

this is my Q


3.Write expressions to compute both solutions for the quadratic formula. The formula is
- b + - ( b^2 - 4ac) / 2a
The - & + symbol means “plus or minus” and indicates that the equation has two solutions: one in which the result of the square root is added to -b and one in which the result is subtracted from -b. Assume all variables are float variables.

this is my answer but when put it in jGRASP , it tell me ERROR !!!

import java.lang.Math; 

public class E3
{
public static void main(String[] args)
{
Scanner console = new Scanner (System.in);

float x,y,a,b,c,f;
double e;

System.out.println("Enter a ");
a =console.nextDouble();

System.out.println("Enter b ");
b = console.nextDouble();

System.out.println("Enter c ");
c = console.nextDouble();

f= (b*b)-(4*a*c);
e= Math.pow(f, 0.5 );

x=(-b + e)/(2*a);
y=(-b - e)/(2*a);

System.out.println("solution1 =" + x);
System.out.println("solution2 =" + y);
}
}

and this is another Q :$

2.Write a java program that reads two integers into the variables a and b then swaps the values of a and b.


I'm so sorry :;s

I notice you are using the standard float numbers and the newer double format which may be the cause of your problems. If so, you may need to cast the double values input into FLOAT to asign them to the declared variables. Alternatively, you could use Double precision throughout the program.


2.Write a java program that reads two integers into the variables a and b then swaps the values of a and b.

public class swapInts
{
public static void main(String[] args)
{
Scanner console = new Scanner (System.in);

int a, b, tempInt;

System.out.println("Enter first Int: ");
a =console.nextInt();

System.out.println("Enter second Int: ");
b = console.nextInt();

tempInt = a; //copy a to temp
a = b; //copy b to a
b = tempInt; //copy temp to b

System.out.println("int 1=" + a);
System.out.println("int 2 =" + b);
}
}

hope this helps...

anuj576 & stevelg

THX 4 u ,, I solved Q 3 and I knw where is my erorr ^^

mruthyunjaya

Thhhhhhhhhhhhhhhnk u

you've helped me thhhx huuuun (F)(F) u'r a heRo


I'v a Q :$

what's meaning of tempInt in

int a, b, tempInt;
tempInt = a; //copy a to temp
b = tempInt; //copy temp to b

Finelly ^^ R u sure from da code ? :$

thx again

Edited 7 Years Ago by GiRL,IT: n/a

@GiRL,IT your use of language is unacceptable. Please make sure you read forum rules where you will find something like

We strongly encourage all posts to be in full-sentence English. Please do not use "leet" speak or "chatroom" speak.

^

okay dear .

I'll do That

Edited 7 Years Ago by GiRL,IT: n/a

mruthyunjaya

Thhhhhhhhhhhhhhhnk u

you've helped me thhhx huuuun (F)(F) u'r a heRo


I'v a Q :$

what's meaning of tempInt in

int a, b, tempInt;
tempInt = a; //copy a to temp
b = tempInt; //copy temp to b

Finelly ^^ R u sure from da code ? :$

thx again

tempInt is just a temporary Integer. we use that to store either a or b value in the process of swapping... hope i am clear..

This article has been dead for over six months. Start a new discussion instead.