Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

Chago Bowers

Greenhorn
+ Follow
since Mar 05, 2014
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chago Bowers

I forgot to put the "out" in the previous post. I mean System.out.println ();
4 years ago
There is no output that followed the command. It is the last command in the code, but when implemented changed the format of the output of the preceding code. When removed from the code the output format for the code is just a straight line. See below:

Without System.println (); at the end of the code
Multiplication Table
1 2 3 4 5 6 7 8 9
-----------------------------------------
1 | 1 2 3 4 5 6 7 8 92 | 2 4 6 8 10 12 14 16 183 | 3 6 9 12 15 18 21 24 274 | 4 8 12 16 20 24 28 32 365 | 5 10 15 20 25 30 35 40 456 | 6 12 18 24 30 36 42 48 547 | 7 14 21 28 35 42 49 56 638 | 8 16 24 32 40 48 56 64 729 | 9 18 27 36 45 54 63 72 81

With System.println (); at the end of the code

Multiplication Table
1 2 3 4 5 6 7 8 9
-----------------------------------------
1 | 1 2 3 4 5 6 7 8 9
2 | 2 4 6 8 10 12 14 16 18
3 | 3 6 9 12 15 18 21 24 27
4 | 4 8 12 16 20 24 28 32 36
5 | 5 10 15 20 25 30 35 40 45
6 | 6 12 18 24 30 36 42 48 54
7 | 7 14 21 28 35 42 49 56 63
8 | 8 16 24 32 40 48 56 64 72
9 | 9 18 27 36 45 54 63 72 81
4 years ago
Thank both of you for your response. So in summary, the System.out.println(); command will take any previous System.out.print commands that are in parenthesis and print them on their own line? I just want to make sure I'm understanding how and what it is doing to the previous commands
4 years ago
How does the last statement in this code System.out.println(); change the format of the table. Before implemented the numbers are in one horizontal line. After adding this statement the table develop rows.




4 years ago
I am working on an exercise where I need to:

(Count positive and negative numbers and compute the average of numbers)
Write a program that reads an unspecified number of integers, determines how many
positive and negative values have been read, and computes the total and average of
the input values (not counting zeros). Your program ends with the input 0. Display
the average as a floating-point number.

I moved the different boolean statements around, but I'm not getting the sentinel value to end the run. It continues to let me add integers endlessly. The code I wrote is below:





4 years ago
Thank you for the quick response. The extra set of parenthesis around the numerator and denominator did the trick. I'll have to remember this in the future. I was frustrated last night because only the first part of the math weight * 0.45359237 was executed and the rest was just ignored by the compiler. I'll remember to also use code when posting in the future
4 years ago
I was trying to execute the following program and the multiplication worked but the division didn't work. Please let me know what I am doing wrong:

import java.util.Scanner;
public class BodyMassIndex {

public static void main(String[] args) {
// Prompt the user for weight and height
// Create a scanner
Scanner input = new Scanner (System.in);
System.out.println("Please enter your weight in pounds");
int weight = input.nextInt();
System.out.println("Please enter your height in inches");
int height = input.nextInt ();
double BMI = weight * (0.45359237)/ (height * 0.0254)*(height * 0.0254);
// the weight * (0.45359237) executed but it wasn't divided by (height * 0.0254)*(height * 0.0254)
System.out.println ("Your BMI is "+BMI);
4 years ago