Michelle Parker

Greenhorn
+ Follow
since Apr 23, 2008
Merit badge: grant badges
For More
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 Michelle Parker

Do you have any basics that a new Java programmer can work on to have the best possible code when starting out (in addition to buying your book)?

Thanks,
Mischelle
I need it to read in the scores from Score.txt
then give the average of them.
15 years ago
Hi Joanne,

It doesn't compile at all. No error messages.
15 years ago
Howdie:

I have issues with this program:

package Scores;

import java.io.*;
import java.util.*;
import java.util.Scanner.*;


public class Scores {
public static void main(String[] args) throws Exception {
int total=0;
int count=0;
// Create a File instance
java.io.File file = new java.io.File("Scores.txt");

// Create a Scanner for the file
java.util.Scanner input = new java.util.Scanner(file);

// Read data from a file
while (input.hasNext()) {
count=count+1;
int score = input.nextInt();
total = total + score;
}
average = total / count;
System.out.println("The total = " +total +"\n"
+ "The average = " +average);

// Close the file
input.close();
}
}

With the Scores.txt containing the following:

55 88 99 50 66 31 45 15 48

Mucho Gracias!
15 years ago
Howdie Partners:

I have the following code and get ye olde ';' Exception error.

Please help me!

import javax.swing.JOptionPane;
import java.util.Scanner;
public class Triangle
{
public static void main (String [] args)
{
double num1, num2, num3; // input values
double total, perimeter;
//get side lengths
Scanner rdr = new Scanner(System.in);

// Define perimeter
perimeter = (num1 + num2 + num3);

// Input the two numbers
System.out.println("Input your first number.");
num1 = console.nextDouble();

System.out.println("Input your second number.");
int num2 = console.nextDouble();

System.out.println("Input your third number.");
int num3 = console.nextDouble();

// Determine the total of the first two numbers
int total = (num1 + num2);
int answer = Integer.parseInt(triangle);

If (answer)
(total > num3 = true);
System.out.print("The perimeter is " + perimeter);

Else (answer)
(total < num3 = false);
System.out.print("The data is incorrect.");

// Show output in a dialogue box
JOptionPane.showMessageDialog(null,
output, JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
Thank you.

Very humbly yours,
Michelle
15 years ago