Printing Highest And Lowest Of Three Numbers Using Java?

Feb 23, 2014

I am working on an assignment but I am not getting any out put and I couldn't fix it?The class HighLow below asks for three integers and prints the highest and lowest of them on screen. Your task is to write the missing methods high and low, which receives the integers user inputs as parameters and return the highest and lowest integers respectively.

import java.util.Scanner;
public class HighLow {
public static void main(String[] args) {
int number1, number 2, number 3, high, low;
Scanner reader = new Scanner(System.in);

[code]......

View Replies


ADVERTISEMENT

Printing Highest And Lowest Of Three Numbers Using Java

Feb 23, 2014

The class HighLow below asks for three integers and prints the highest and lowest of them on screen. Your task is to write the missing methods high and low, which receives the integers user inputs as parameters and return the highest and lowest integers respectively.

import java.util.Scanner;
public class HighLow {
public static void main(String[] args) {
int number1, number 2, number 3, high, low;
Scanner reader = new Scanner(System.in);

[code]....

View Replies View Related

Java Program - Find Next Highest Or Lowest Prime Number

May 2, 2014

Java program takes positive int from user and determine if prime. Next the program finds next highest or next lowest prime number.

import java.io.*;
import java.util.*;
public class pa2take2 {
public static void main (String[]args){
int menus; //menu selection

[Code] ......

View Replies View Related

Write A JAVA Program That Will Input 10 Scores And Output Highest And Lowest Score

Jan 9, 2015

1.Write a JAVA program that will input 10 scores and output the Highest and Lowest score.

2.Write a JAVA program that will input the base and power and display the result: Example: Base is 4 Power is 2 the answer is 16 (Note: Math.pow( ) method is not allowed)

3.Write a JAVA program that will input an integer number, and then will output the sum of all inputted numbers. The program will stop in accepting inputs if the user entered 0.

View Replies View Related

Calling Methods For Java GradeBook - Calculate Highest And Lowest Grades In Array

Apr 15, 2015

In this project each individual will create a data analysis program that will at a minimum,

1) read data in from a text file,
2) sort data in some way,
3) search the data in some way,
4) perform at least three mathematical manipulations of the data,
5) display results of the data analysis in numeric/textual form, and
6) display graphs of the data. In addition,
7) your program should handle invalid input appropriately and
8) your program should use some "new" feature that you have not been taught explicitly in class.

(Note: this is to give you practice learning new material on your own - a critical skill of today's programmer.) If you do not have a specific plan in mind for your project, below is a specific project that meets all of the qualifications as long as 7) and 8) are addressed in the implementation.

Everything is done except I need to call my methods in my GradeTester.

GradeBook:

/**
*This class creates an array called scores.
*This class determines the length of the array scores and determines the last grade in the array scores.
*This class sorts the array using a bubble sort, and searches the array.
*This class calculates the mean, standard deviation, and the median of the grades in the array scores.
*Once the grades in the array is sorted, the class then calculates the highest and lowest grades in the array.
*/

public class GradeBook {
public final int MAXARRAY_SZ = 20;
double [] scores = new double [MAXARRAY_SZ];
int lastGrade = 0;
double mean = 0;

[Code] ....

View Replies View Related

Sorting From Lowest To Highest

Feb 23, 2014

I'm very new to Java and ran into a problem. My results are not in order and I'm not sure what I'm doing wrong.

My results come out like this instead of being in order from lowest to highest: "77 99 44 55 22 88 11 0 66 33"

Here's what I have:

class ArrayIns {
private long[] a; // ref to array a
private int nElems; // number of data items
//--------------------------------------------------------------
public ArrayIns(int max) // constructor
{
a = new long[max]; // create the array
nElems = 0; // no items yet

[Code] .....

View Replies View Related

Display All Student With Their Grade Sorted From Highest To Lowest

Oct 22, 2014

Write a program that promts a professor to input grades for five different courses for 10 students. Prompt the professor to enter only A,B,C,D, or F for grades(A is the highest grade, F fail). use variables for student number(1 through 10) and grade numbers(1 through 5). create a menu for Search. if the user select search it will prompt a letter correspond to grade. display all student with selected grade. if the user just enter nothing, display all student with their grade sorted from highest to lowest.

View Replies View Related

Reading Lowest / Highest / Average Grades And Reporting Them From For Loops?

May 3, 2014

import java.util.*;
import java.text.*;
public class Quiz {
public static void main(String[] args){
Scanner s= new Scanner(System.in);
int quests = 0;
String input ="";

[code]....

I'm not getting any errors anymore.

View Replies View Related

Print Only Top 15 Highest Numbers Of Occurrence From RNG Output

Oct 15, 2014

I created a random number generator for my course and it works perfectly. I now need to print only the top 15 highest numbers of occurrence from the RNG output. How i can do this?

Here is my block of code.

package section4;
import java.util.Random;
public class Lottery {
public static void main(String[] args) {
Random rand = new Random();
int freq[] = new int[51];

[Code] ....

View Replies View Related

How To Make A Program That Determines The Highest Value Out Of Inputted Numbers

Sep 14, 2014

how to make a program that determines the highest value out of the inputted numbers.

View Replies View Related

Display Lowest And Then Next Lowest Number From Array

Jan 5, 2015

I am not getting the result I am looking for, but I'm sure I'm on the right track. I have an array, names + times of marathon runners, and should end up with a program that displays the slowest runner, and the next-slowest runner.

Currently, I get this:
The lowest time is 273.
The lowest time is 243.

Changing names.length to times.length changes nothing.
for (i = 1;... ) changes nothing.

The displayed number should currently only be 243. Why is it displaying 273 first, and at all?

The code:

class Marathon {
public static void main (String[] arguments) {
String[] names = {"Elena", "Thomas", "Hamilton", "Suzie", "Phil", "Matt", "Alex", "Emma", "John", "James", "Jane", "Emily", "Daniel", "Neda", "Aaron", "Kate"};
  int[] times = {341, 273, 278, 329, 445, 402, 388, 275, 243, 334, 412, 393, 299, 343, 317, 265};
  int min = times [0];
  for (int i = 0; i < times.length; i++) {
if (times[i] < min){
min = times[i];
System.out.println("The lowest time is " + min +".");
}

View Replies View Related

Alphabets And Numbers - Printing Out In A Row

Dec 1, 2014

The code below gives me an alphabet and the numbers 0-9 printed out in column, the job is to print it in line (in a row).
 
/**
* Alphabet and numbers
*/
public class Alphabet {
public static void main() {
char letter;
char number;

[Code] ....

View Replies View Related

Printing Distinct Numbers

Feb 8, 2015

so for class I have an assignment that involves printing distinct numbers. the assignment is as follows: Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly on space. Here is what the input and the output are supposed to look like:

Input: Enter Ten Numbers: 1 2 3 2 1 6 3 4 5 2
Output: The Number of distinct numbers is 6
The distinct numbers are: 1 2 3 6 4 5

So far I have the entire code but right now it only prints out the distinct numbers, not how many distinct numbers there are. what that part of the code would look like?Here is my current code:

public class exer75 {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in); //create scanner system
System.out.println("");
System.out.print("Enter Ten Numbers: "); //prompt the user to enter 10 numbers
int[] values = new int[10]; //create an array to hold the numbers

[code]...

View Replies View Related

Printing Number Of Prime Numbers In A Range?

Feb 13, 2015

The assignment is to make a program that prints the number of prime numbers in a range. This is what i have so far. The output is a list of 2s. I created the for loop to cycle through the range of 17-53 and nested a while loop within to test each incident of the for loop to check for divisors starting with 2 until the modulus result is 0 resulting in a false for being a prime number. Then the loop should increment to the next i value. The last part is an if statement that i had intended to add counters to the k variable that would keep track of the number of prime numbers.

boolean isPrime = true;
int j = 2;
int k = 1;
for (int i = 17; i <= 53; i++){
{
while (i % j == 0){
isPrime = false;

[Code] .....

View Replies View Related

Rational Numbers - Class Not Printing Properly

Nov 10, 2014

I am creating a program for rational numbers but it does not work properly when I enter a negative number in the denominator. It works with every other number.

import java.io.*;
import java.util.Scanner;
public class RationalNumber {
private int numerator;
private int denominator;

[Code] ....

View Replies View Related

Printing Fibonacci Numbers - Illegal Start Of Expression

Nov 1, 2014

Here is my program and results and I am having a error on line 38 which is "public static long fib01(long paramLong)" The program does give me my results but I am trying to correct there error.

public static void main(String[] args) {
{
System.out.print("

" + String.format("%-10s", new Object[] { "Index" }));
System.out.print(String.format("%-15s", new Object[] { "Fibonacci01" }));
System.out.print(String.format("%-15s", new Object[] { "Fibonacci02" }));
System.out.println(String.format("%-15s", new Object[] { "Fibonacci01" }));

[Code] ....

Index Fibonacci01 Fibonacci02 Fibonacci01
--------------------------------------------------
0 0 0 0
1 1 1 1
2 1 1 1
3 2 2 2
4 3 3 3
5 5 5 5
6 8 8 8
7 13 13 13
8 21 21 21
9 34 34 34
10 55 55 55
11 89 89 89
12 144 144 144
13 233 233 233
14 377 377 377
15 610 610 610
16 987 987 987
17 1597 1597 1597
18 2584 2584 2584
19 4181 4181 4181
20 6765 6765 6765
21 10946 10946 10946
22 17711 17711 17711
23 28657 28657 28657
24 46368 46368 46368
25 75025 75025 75025
26 121393 121393 121393
27 196418 196418 196418
28 317811 317811 317811
29 514229 514229 514229
30 832040 832040 832040

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - illegal start of expression
at fibonacci.Fibonacci.main(Fibonacci.java:38)
--------------------------------------------------Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

View Replies View Related

Checking If Int Is Lowest Out Of 4?

Apr 30, 2014

I'm trying to find the int with the lowest value, and I only know how to set it up like this:

Let's say x1 is the lowest.

int x1, x2, x3, x4;
 
if (x1 < x2 && x1 < x3 && x1 < x4) System.put.println("x1 is the lowest value out of those 4");

Is there a way to shorten this at all? (It's alright if there isn't, just looking for shortcuts)

View Replies View Related

Calculate Lowest Value Of Array

Feb 13, 2015

So I have this code to calculate the lowest value of an array:

public class Exercise1 {
public static void main(String[] args) {
int[] theArray = {1/*/,2,3,4,5,6,7,8,9,10/*/};
int result = Exercise1.min(theArray);
System.out.println("The minimum value is: " +result);

[code].....

and I need to write an exception class that should be thrown if the array does not hold any elements.

View Replies View Related

Find The Lowest Number?

Apr 12, 2014

I have to find the average, highest, and lowest numbers in an array. I already have the average and highest, and I thought I could find the lowest number the same way I found the highest, but it's not working. It just keeps coming out to 0. I've tried out different ways, but I want to see if there are better ways than doing MAX_VALUE for the lowest, then looping it through.

import java.util.Scanner; 
public class Test_Scores {
public static void main(String[] args) {
//array,scanner,values

[Code].....

View Replies View Related

How To Return 2 Lowest Scores

Mar 19, 2015

If this method returns the lowest score, how do I return the 2 lowest scores.

For example If I input 1, 2, 3, 4, 5 this code will return 1.

How do i return the two lowest scores, for example if I input 1, 2, 3, 4, 5, I want to return 1, 2

public double getLowestScore() {
smallest = testScores[0];
double sum = 0.0;
double total = 0.0;
double Average = 0.0;

[Code] ....

View Replies View Related

Return Lowest Value From Array

Aug 12, 2014

I am trying to return the lowest value from the array. having trouble trying to capture the return value by placing it into the variable ..

int myLowest = getLowest(yourNumbers); and then printing out myLowest

import java.util.*;
public class numArrays
{
public static void main(String[] args){
int numbers;
int[]yourNumbers;

[code]....

View Replies View Related

Batch Printing Of Files In Java

May 21, 2014

One challenging task in java i am facing is, batch printing of files in java .....

View Replies View Related

Printing Array Elements In Java

Oct 15, 2014

I have tried to print array elements using standard print statement. I am getting errors. How to print them. Here is my code:

class arrayEx1{
public static void main(String args[]) {
int a[]=new int[3]; //Declaring Single Diomentional Array
a[0]=10;
a[1]=20;
a[2]=30;
int total=a[0]+a[1]+a[2];
System.out.println("Values stored in a[0],a[1],a[2]elements are :" + a[0] a[1] a[2]);
System.out.println("Total values of a[0],a[1],a[2]elements is :"+ total);
}
}

if i give comma (,) in between above print stament (print statement 1) stil i am getting errors.

View Replies View Related

Printing From Java Application To USB Printer

Apr 28, 2014

How can I print to a USB printer from my Java application? I've always printed to network printers using IP addresses.

View Replies View Related

Java Printing HTML Document

Nov 18, 2014

My current calculator (currently available on my site) launches your default webbrowser with the CalculatorHistory file allowing you to print through your browser, but I been working on self contain the html page in a the JEditorPane which is great it does what i want, so I started working on the printing side and I am stuck...

The code I have was from a example (modified) but when I run the code I get the following error:

Exception in thread "main" java.lang.IllegalArgumentException: services must be non-null and non-empty
at javax.print.ServiceUI.printDialog(Unknown Source)
at gcclinux.co.uk.PrintReport.main(PrintReport.java:28)

The Line 28 equals to PrintService service = ServiceUI.printDialog(null, 200, 200,printService, defaultService, flavor, pras);

package gcclinux.co.uk;
import java.io.FileInputStream;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;

[Code] .....

View Replies View Related

Printing Textfile Through A Printer From Java

Jan 7, 2015

I want to print a text file from java by clicking on a JButton. How to use PrintJob for that?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved