<M/> 170 Why so serious? Featured Poster

So your saying to do it like this:

import java.util.Scanner;
import java.text.DecimalFormat;
public class ReverseNumber {

   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       System.out.print("Enter a positive integer: ");
       long input = s.nextLong();
       long temp= input*2;
       long result = reverse(temp);
       DecimalFormat myFormatter = new DecimalFormat("#,##0");
       System.out.println(myFormatter.format(input) + " doubled is " + myFormatter.format(input*2) + " and then reversed is " + myFormatter.format(reverse(result)));
   }

   public static long reverse(long n) {
       long result = 0;
       long rem;
       while (n > 0) {
           rem = n % 10;
           n = n / 10;
           result = result * 10 + rem;
       }
       return result;
   }
}

Doing it this way will make be like input being 20, doubled is 40 and reversed 40? Doesn't doing it this way make doubled show up in twice rather than making one of the doubles flip/reverse (i think i worded that awkwardly). Here is an error log that i got (I think i may have forgot to do something in the code):

First Difference Occurs at: byte 82, line 1
On Line 1 its column 82
Line 1 Wrong: Enter a positive integer: 52,010,023 doubled is 104,020,046 and then reversed is 104,020,046
Line 1 Right: Enter a positive integer: 52,010,023 doubled is 104,020,046 and then reversed is 640,020,401 
You have only a First Line Error
<M/> 170 Why so serious? Featured Poster

This maybe a ridiculous question but how would you do that within my code? I can see what happens with input==0 but where would num++ go?

<M/> 170 Why so serious? Featured Poster

I am compiling this using the teacher's grading compiler... Could something be wrong with the teacher's compiler? Or is there a better way to write my code that maybe acceptable for the teacher's compiler?

<M/> 170 Why so serious? Featured Poster

@AD, i know what is standard deviation and how to find it but i wasn't sure how to do it and implement in java.

Do you know how to implement it within my code?

<M/> 170 Why so serious? Featured Poster

I am trying to write a program to calculate mean & standard deviation.

I sort of figured out how to find mean (it is not correct yet, so i am going to need help on this part as well) but how do you do standard deviation?

import java.util.Scanner;

public class Mean {
    public static void main(String[] args){
      int sum = 0, inputNum;
      int counter;
      float mean;
      Scanner NumScanner = new Scanner(System.in);
      Scanner charScanner = new Scanner(System.in);

      System.out.println("Enter the total number of terms whose mean you want to calculate");

      counter = NumScanner.nextInt();

      System.out.println("Please enter " + counter + " numbers:");

      for(int x = 1; x<=counter ;x++){
          inputNum = NumScanner.nextInt();
          sum = sum + inputNum;
          System.out.println();
      }

      mean = sum / counter;
      System.out.println("The mean of the " + counter + " numbers you entered is " + mean);
    }
}

The above is what i have so far, there are errors but hopefully we can build from there?

<M/> 170 Why so serious? Featured Poster

This is currently my code:

import java.util.Scanner;


public class Distance
{
    static double distance(double x1, double y1, double x2, double y2)
                {
                return Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
                }
    public static void main(String[] args)
    {
        double x2, x1, y2, y1;
        double distance;

                Scanner scan = new Scanner (System.in);

                    System.out.println("Enter two points: ");
                    x1 = scan.nextDouble();
                    y1 = scan.nextDouble();
                    x2 = scan.nextDouble();
                    y2 = scan.nextDouble();



                    distance = distance(x1,y1,x2,y2);

                    System.out.println("The distance between the two points is " + distance + " .");

    }

}

and this is the error log:

First Difference Occurs at: byte 19, line 1
On Line 1 its column 19
Line 1 Wrong: Enter two points: 
Line 1 Right: Enter two points: The distance between the two points is 514.03 

sdiff side by side difference your output versus solution....
Enter two points:                         | Enter two points: The distance between the two points is 514.
The distance between the two points is 514.0316721759467 .    <

Octal Dump Difference
0000020   :      \n   T   h   e       d   i   s   t   a   n   | 0000020   :       T   h   e       d   i   s   t   a   n   c  
0000040   b   e   t   w   e   e   n       t   h   e       t   | 0000040   e   t   w   e   e   n       t   h   e       t   w  

Octal Dump Your output...
0000000   E   n   t   e   r       t   w   o       p   o   i   n   t   s
0000020   :      \n   T   h   e       d   i   s   t   a   n   c   e    
0000040   b   e   t   w   e   e …
<M/> 170 Why so serious? Featured Poster

This is a code that I wrote and for some odd reason it doesn't count the number of inputted integers properly.

import java.util.Scanner;
public class IntegerCount
{
public static void main(String[] args)
{

    Scanner input = new Scanner(System.in);
        System.out.print("Enter an integer, the input ends if it is 0: ");
int num = input.nextInt();

        if ( num == 0 ){
  System.out.println("No numbers were entered except 0");
}
else{
  System.out.println("The number of integers is " + num);
}


}
}

If i were to enter lets say 9 numbers, it will say 2 numbers instead of 9. If i enter 25, it will say 500 instead of 25. The only time it works is if you enter a number like 0.

can someone help me with this?

<M/> 170 Why so serious? Featured Poster

oh, each one of those were causing an issue because they had a syntax issue... i wrote about 30 queries for the assignment but those were the few that had syntax issues that i am not understanding.

whichever you're using to find the error yourself?

The teacher's compiler is indicating that those had errors.

<M/> 170 Why so serious? Featured Poster

I am trying to reverse the number that is doubled from the user input.

Problem is that if they enter a number like 20000 it gets doubled into 40000 but it reverses it to 2 rather than 4. How do i get it to make the doubled number reversed and the original number to not get reversed.

Here is my code, it is pretty simple but there is just that one problem...:

import java.util.Scanner;
import java.text.DecimalFormat;
public class ReverseNumber {

   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       System.out.print("Enter a positive integer: ");
       long input = s.nextLong();
       long result = reverse(input);
       DecimalFormat myFormatter = new DecimalFormat("#,##0");
       System.out.println(myFormatter.format(input) + " doubled is " + myFormatter.format(input*2) + " and then reversed is " + myFormatter.format(reverse(result)));
   }

   public static long reverse(long n) {
       long result = 0;
       long rem;
       while (n > 0) {
           rem = n % 10;
           n = n / 10;
           result = result * 10 + rem;
       }
       return result;
   }
}
<M/> 170 Why so serious? Featured Poster

I need help with the queries I wrote and I don't understand what is wrong with them? Can someone help me correct them?

#11
SELECT BOOK_CODE, TITLE, PUBLISHER.PUBLISHER_CODE, PUBLISHER_NAME 
FROM BOOK, PUBLISHER 
WHERE PUBLISHER.PUBLISHER_CODE = BOOK.PUBLISHER_CODE 
ORDER BY PUBLISHER_NAME;
#12
SELECT BOOK_CODE, TITLE, PRICE 
FROM BOOK, PUBLISHER 
WHERE PUBLISHER_NAME = 'Plume' 
AND BOOK.PUBLISHER_CODE = PUBLISHER.PUBLISHER_CODE;
#13
SELECT BOOK_CODE, TITLE, PRICE 
FROM BOOK, PUBLISHER 
WHERE PUBLISHER_NAME = 'Plume' 
AND BOOK.PUBLISHER_CODE = PUBLISHER.PUBLISHER_CODE 
AND PRICE >= 14;
#14
SELECT TITLE, BOOK.BOOK_CODE, ON_HAND, BRANCH.BRANCH_NUM 
FROM BOOK, BRANCH, INVENTORY 
WHERE BRANCH.BRANCH_NUM = 4 
AND BOOK.BOOK_CODE = INVENTORY.BOOK_CODE 
AND INVENTORY.BRANCH_NUM = BRANCH.BRANCH_NUM;
#15
SELECT TITLE 
FROM BOOK, PUBLISHER 
WHERE TYPE = 'PSY' 
AND PUBLISHER_NAME = 'Jove Publications' 
AND BOOK.PUBLISHER_CODE = PUBLISHER.PUBLISHER_CODE ;
#16
SELECT TITLE, BOOK_CODE 
FROM BOOK 
WHERE BOOK_CODE 
IN (SELECT BOOK_CODE FROM WROTE WHERE AUTHOR_NUM =18);
#17
SELECT A.BOOK_CODE,  B.BOOK_CODE, A.PRICE FROM BOOK A, BOOK B WHERE A.PRICE=B.PRICE AND A.BOOK_CODE < B.BOOK_CODE ORDER BY A.BOOK_CODE, B.BOOK_CODE;
#18
SELECT BOOK.BOOK_CODE, TITLE FROM BOOK, WROTE, INVENTORY WHERE INVENTORY.BRANCH_NUM = 2 AND AUTHOR_NUM = 20 AND BOOK.BOOK_CODE = WROTE.BOOK_CODE AND INVENTORY.BOOK_CODE = BOOK.BOOK_CODE;
#19
SELECT A.BOOK_CODE, B.BOOK_CODE, A.PRICE FROM BOOK A, BOOK B WHERE A.PRICE=B.PRICE AND A.BOOK_CODE < B.BOOK_CODE ORDER BY A.BOOK_CODE, B.BOOK_CODE;
#20
SELECT TITLE, AUTHOR_LAST, ON_HAND FROM WROTE, BOOK, BRANCH, INVENTORY, AUTHOR WHERE BRANCH.BRANCH_NUM = 4 AND BOOK.BOOK_CODE = INVENTORY.BOOK_CODE AND BOOK.BOOK_CODE = WROTE.BOOK_CODE AND INVENTORY.BRANCH_NUM = BRANCH.BRANCH_NUM AND WROTE.AUTHOR_NUM = AUTHOR.AUTHOR_NUM;
#6
SELECT CUSTOMER_NUM, CUSTOMER_NAME
FROM CUSTOMER WHERE CUSTOMER.CUSTOMER_NUM
NOT IN (SELECT CUSTOMER_NUM FROM ORDERS WHERE ORDER_DATE = '2007-10-21');

Can someone …

<M/> 170 Why so serious? Featured Poster

But Fred is wearing jeans and has messy hair!

Yeah, he is a dorky accountant that works at home and doesn't brush his hair :D

<M/> 170 Why so serious? Featured Poster

Granted, everyone was good and you couldn't take their souls because they don't do bad things.

I wish i made a million dollars for every action i do.

<M/> 170 Why so serious? Featured Poster

@Learner, but where in the snippet you have provided limits the amount of numbers that get outputted? Instead of displaying all of the pentagonal numbers, how about just a few (like 5)?

<M/> 170 Why so serious? Featured Poster

Welcome!

<M/> 170 Why so serious? Featured Poster

Granted, you were eaten... the end!

I wish i was santa

<M/> 170 Why so serious? Featured Poster

granted, you got an F ;D

I wish I missed school today

<M/> 170 Why so serious? Featured Poster

Expendables

<M/> 170 Why so serious? Featured Poster

Yo mama is so stupid that she thinks Tiger Woods is a forest in India.

<M/> 170 Why so serious? Featured Poster

That's one way to do it.
A more experienced programmer would probably separate the user interface from the calculation.
The initialisations on line 7-9 are redundant because those values are never used.
There's a much simpler formula for the area of a triangle defined by three Points a,b,c:
0.5*((a.x - c.x) * (b.y - a.y) - (a.x-b.x) * (c.y-a.y))

oh okay, i see what you meant there.i wll keep that in mind the next time i do something like this.

<M/> 170 Why so serious? Featured Poster

Granted, you had a coma and now it is monday ;D

I wish i was starbucks cup of coffee

<M/> 170 Why so serious? Featured Poster

That was actually some other online retailer, KlearGear.com

oh, thanks for the correction.

<M/> 170 Why so serious? Featured Poster

Okay, so here is what i ended up with:

import java.util.Scanner;
public class Pentagonal {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter an integer: ");
        long n = input.nextInt();
        System.out.print("The pentagonal numbers are: ");
        getPentagonalNumber(n);
    }
    public static long getPentagonalNumber(long n) {


    int n1 = 1;
    while (n<=100) {
        n = (3*n1*n1 - n1)/2;
        System.out.print(n + " ");
        n1++;
    }
    return n;
    }
}

but how do you limit the output to 5 numbers?

<M/> 170 Why so serious? Featured Poster

So you mean like this:

import java.util.Scanner;
public class Pentagonal {

    public static void main(String[] args) {

        System.out.print("The Pentagonal Numbers: ");
        getPentagonalNumber(10);
    }

    public static int getPentagonalNumber(int n) {

        Scanner input = new Scanner(System.in);
System.out.print(
"Enter an integer: ");
long n = input.nextInt();
        int n1 = 1;
        int count = 1;
        while (n<=100) {
            n = (3*n1*n1 - n1)/2;
            System.out.println(n);
            n1++;
            count++;
        }
        return n;

    }

}

but this gives me errors? Is that right?

<M/> 170 Why so serious? Featured Poster

Sorry, i couldn't get the image to enlarge...

<M/> 170 Why so serious? Featured Poster

I opted, instead, for a deep dish apple pie (with cinnamon).

homemade?

<M/> 170 Why so serious? Featured Poster

I am trying to do an assignment that requires us to do something with pentagonal numbers. This is my code:

import java.util.Scanner;
public class Pentagonal {

    public static void main(String[] args) {

        System.out.print("The Pentagonal Numbers: ");
        getPentagonalNumber(10);
    }

    public static int getPentagonalNumber(int n) {

        Scanner input = new Scanner(System.in);
System.out.print(
"Enter an integer: ");
long n = input.nextInt();
        int n1 = 1;

        while (n<=100) {
            n = (3*n1*n1 - n1)/2;
            System.out.println(n);
            n1++;
        }
        return n;

    }

}

I am trying to make the output look like this:

Sample Run 1:
Enter an integer: 2
The pentagonal numbers are: 1 5

Sample Run 2:
Enter an integer: 4
The pentagonal numbers are: 1 5 12 22
<M/> 170 Why so serious? Featured Poster

This is how you calculate the area of a triangle, hope you guys find this useful.

import java.text.DecimalFormat;
import java.util.Scanner;

public class Exercise2_15 {
    // find the area of a triangle
    public static void main (String [] args) {
        double side1 = 0;
        double side2 = 0;
        double side3 = 0;

        Scanner input = new Scanner(System.in);

        //obtain three points for a triangle
        System.out.print("Enter three points for a triangle: ");
        double side1x  = input.nextDouble();
        double side1y  = input.nextDouble();
        double side2x  = input.nextDouble();
        double side2y  = input.nextDouble();
        double side3x  = input.nextDouble();
        double side3y  = input.nextDouble();

        //find length of sides of triangle
        side1 = Math.sqrt(Math.pow((side2x - side1x), 2)+ Math.pow((side2y - side1y), 2));

        side2 = Math.sqrt(Math.pow((side3x - side2x), 2)+ Math.pow((side3y - side2y), 2));

        side3 = Math.sqrt(Math.pow((side1x - side3x), 2)+ Math.pow((side1y - side3y), 2));


        double s = (side1 + side2 + side3) / 2;

        double area = Math.sqrt(s * (s - side1) * (s - side2) * (s-side3));

        DecimalFormat myFormatter = new DecimalFormat("#,##0.00");

        System.out.println("The area of the triangle is " + myFormatter.format(area));
    }
}
<M/> 170 Why so serious? Featured Poster

Okay... i will admit, i am pretty stupid for not catching the mistake.

Here is the proper code for it:

import java.text.DecimalFormat;
import java.util.Scanner;

public class Exercise2_15 {
    // find the area of a triangle
    public static void main (String [] args) {
        double side1 = 0;
        double side2 = 0;
        double side3 = 0;

        Scanner input = new Scanner(System.in);

        //obtain three points for a triangle
        System.out.print("Enter three points for a triangle: ");
        double side1x  = input.nextDouble();
        double side1y  = input.nextDouble();
        double side2x  = input.nextDouble();
        double side2y  = input.nextDouble();
        double side3x  = input.nextDouble();
        double side3y  = input.nextDouble();

        //find length of sides of triangle
        side1 = Math.sqrt(Math.pow((side2x - side1x), 2)+ Math.pow((side2y - side1y), 2));

        side2 = Math.sqrt(Math.pow((side3x - side2x), 2)+ Math.pow((side3y - side2y), 2));

        side3 = Math.sqrt(Math.pow((side1x - side3x), 2)+ Math.pow((side1y - side3y), 2));


        double s = (side1 + side2 + side3) / 2;

        double area = Math.sqrt(s * (s - side1) * (s - side2) * (s-side3));

        DecimalFormat myFormatter = new DecimalFormat("#,##0.00");

        System.out.println("The area of the triangle is " + myFormatter.format(area));
    }
}
<M/> 170 Why so serious? Featured Poster

Hi guys, i am trying to find the area of a triangle and for some odd reason i can't get it to produce the right numbers.

Here is my code:

import java.util.Scanner;

public class Exercise2_15 {
    // find the area of a triangle
    public static void main (String [] args) {
        double side1 = 0;
        double side2 = 0;
        double side3 = 0;

        Scanner input = new Scanner(System.in);

        //obtain three points for a triangle
        System.out.print("Enter three points for a triangle: ");
        double side1x  = input.nextDouble();
        double side1y  = input.nextDouble();
        double side2x  = input.nextDouble();
        double side2y  = input.nextDouble();
        double side3x  = input.nextDouble();
        double side3y  = input.nextDouble();

        //find length of sides of triangle
        side1 = Math.sqrt(Math.pow((side2x - side1x), 2)+ Math.pow((side2y - side1y), 2));

        side2 = Math.sqrt(Math.pow((side3x - side2x), 2)+ Math.pow((side3y - side2y), 2));

        side3 = Math.sqrt(Math.pow((side1x - side3x), 2)+ Math.pow((side1y - side3y), 2));


        double s = (side1 + side2 + side3) / 2;

        double area = Math.sqrt(s * (s - side1) * (s - side2) * (s-side3)) * 0.5;

        System.out.println("The area of the triangle is " + area);
    }
}

Here are the error logs:

First Difference Occurs at: byte 64, line 1
On Line 1 its column 64
Line 1 Wrong: Enter three points for a triangle: The area of the triangle is 47.17000000000089
Line 1 Right: Enter three points for a triangle: The area of the triangle is 94.34 
You have only a First Line Error

sdiff side by side difference your output versus solution....
Enter three …
<M/> 170 Why so serious? Featured Poster

granted, you fail in that school...

I wish my skin was green

<M/> 170 Why so serious? Featured Poster

Alright so here is what i ended up with, and now it doesn't collect inputs :( anyone able to fix it?

import java.util.Scanner;
public class Distance
{
    static double distance(double x1, double y1, double x2, double y2)
                {
                return Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
                }
    public static void main(String[] args)
    {
        double x2, x1, y2, y1;
        double distance;

                Scanner scan = new Scanner (System.in);

                    System.out.println("Enter two points: ");
                    x1 = scan.nextDouble();
                    y1 = scan.nextDouble();
                    x2 = scan.nextDouble();
                    y2 = scan.nextDouble();     
                    distance = distance(x1,y1,x2,y2);
                    System.out.println("The distance between the two points is " + distance + " .");

    }

}
<M/> 170 Why so serious? Featured Poster

and what is your wish?

<M/> 170 Why so serious? Featured Poster

You HAVE to grow old, but growing up is optional

haha, sounds like me ;)

<M/> 170 Why so serious? Featured Poster

@sciwizeh, i don't know if it is me, but i think "a" is trying to make a game like tetris?

<M/> 170 Why so serious? Featured Poster

The main difference is that Fluid Layouts (also called Liquid Layouts) are based on proportionally laying out your website so elements take up the same percent of space on different screen sizes, while Responsive Design uses CSS Media Queries to present different layouts based on screen sizes/type of screen. For some examples of both kinds of design, see Inspiration: Fluid & Responsive Design.

Fluid's intent is to keep the same spatial weighting to all elements, and works okay on different sizes of screens of the same sort. They tend to look okay on a 32", high resolution monitor and a 12" lower resolution laptop. They're pretty easy to implement.

Responsive design's intent is to serve different devices layouts tailored specifically for the type of screen. Your site's layout will generally be cut down to a single column on a smartphone for example.

(Not from my words, but this is what someone else has said)

iamthwee commented: haha thanks +14
<M/> 170 Why so serious? Featured Poster

Also be sure to not share your admin account information with anyone. I recommend changing your password. On the side note, try not using Admin as your username, you will most likely be targetted for a hack :D

<M/> 170 Why so serious? Featured Poster

yo momma is so old, this is how her birthday cake candles looked like: http://files.doobybrain.com/wp-content/uploads/2008/11/california-fires.jpg

<M/> 170 Why so serious? Featured Poster

Got you beat. I'm turning 60 on Sunday.

Man, you must need to get a big cake then if your going to fit all those candles :D

I am turning 16 in 2 months, lets hope i become more mature... :D

<M/> 170 Why so serious? Featured Poster

Granted, you ended up being a hockey player and this is what happened to you: http://www.youtube.com/watch?v=pz9njKh5CLw

I wish I graduated high school

<M/> 170 Why so serious? Featured Poster

Granted, Well... your mom decided to clean the house and sold the pc... ;D

I wish I was able to drive.

<M/> 170 Why so serious? Featured Poster

granted, you landed in south america.

i wish i was a bullet

<M/> 170 Why so serious? Featured Poster

hmmmm, i think i forgot about that thread... let me read it.

<M/> 170 Why so serious? Featured Poster

Trouble - Taylor Swift

<M/> 170 Why so serious? Featured Poster

Radioactive - Imagine Dragons

<M/> 170 Why so serious? Featured Poster

Yes. And I'm glad Fred is gone!

thank goodness, fred was beginning to annoy me...

<M/> 170 Why so serious? Featured Poster

I wrote 2 queries and I am not sure what is wrong with them.

Can someone tell me what to do in order to fix them?

#T8
select sum( quantity ) * (select price from fruit where name like 'apple')
from inventory
where fruitID=(select fruitID from fruit where name like 'apple');

#T9
select price*sum( quantity ) from fruit as f, inventory as i where f.fruitID = i.fruitID group by i.fruitID;
<M/> 170 Why so serious? Featured Poster

mine is the christmas carol movie with jim carrey.

<M/> 170 Why so serious? Featured Poster

I am working on getting an A on one of the few computer classes I enrolled in, right now I have a B and there is about 6 days left in the class :(

<M/> 170 Why so serious? Featured Poster

So I am reading a book from Pratt and it is called A Guide to MySQL. Apparently the book stinks and I am trying to answer some of the questions from the book.

#fc1 show tables in the current selected database 
# for your current database it should be two fruit and inventory
show tables;

#fc2 wait til you cover intrinsics video 2
select name, price from fruit where price > (select avg( price ) from fruit );

#fc3 wait til you cover combining tables video 3
select fruitID, name, 

concat( "$", price) as "unit price",

(select sum( quantity ) from inventory where inventory.fruitID = fruit.fruitID )
as "total quantity"

from fruit order by fruitID ASC;

#fc4 Write query to insert peach w fruitID 5, name peach and price $1.25
#note I cannot test the output from insert so this query will pass
#but if the insert is wrong the next query will fail

#fc5 display fruit name and price  sorted by ascending price, then by name lexicographically
# hint this is just order by price asc, name asc;
# hint remember never specify database names with submit


#fc6 delete peach from fruit table - 
# make sure insert and delete work, if not you may get errors later

#fc7 display each inventory row for apple

#fc8 Display name, and sum( quantity ) for Apple


#fc9 display fruit row of only most expensive fruit, hint sort descending and limit, discussed in video 1

#fc10 display average price of Table:fruit …
<M/> 170 Why so serious? Featured Poster

Are you finding yourself using the new homepage now?

Yep :D