Write an application that reads five integers, determines and prints the largest and smallest integers in the group. Use only the programming techniques you learned in this chapter. (which means: use only if statements and the equality and relational operators).If I want to solve this I will write nested if statements for every probability like the following.The probability: the first integer is the largest and the fifth integer is the smallest:
Project is due before midnight eastern time (3 more hours). I have been working on this all day, we have not learned arrays or anything and just started 'for' loops. I don't really know how to implement that system yet. However, he wants us to check all the possible handwritten math ways of doing this. I have tried but I cannot return my numbers beside the card.my program only prints the type and I still have more cases to add as well..
QUESTION: Write a Java program that reads 5 integers, each of which is in the range of 1 and 13 representing a simplified poker card with no suit. Your program should then print the ranking of the hand with card number(s) beside the ranking. The rankings to determine are Four of a Kind(4 of the 5 cards of the same rank), Full House(3 of the 5 cards of the same rank, and 2 cards of another rank), Straight(5 cards of sequential rank), Three of a Kind(only 3 cards of the same rank), Two Pair(2 cards of the same rank, 2 cards of another rank, and no card of either rank), One Pair(only 2 of 5 cards are of the same rank), and High Card(no two cards of the same rank). Some sample runs are:
input: 2, 3, 2, 2, 2; output: Four of a Kind(2) input: 2, 3, 2, 3, 2; output: Full House(2, 3) input: 2, 3, 4, 5, 1; output: Straight(5) input: 1, 13, 11, 10, 12; output: Straight(1)
a. Assume that we have a list of employees' names of a company and their ages. Write a program that reads from the user several lines of input. Each line includes an employee's name and his/her age (as an integer). The program should calculate and print the following:
- The average age of all employees (rounded to 2 decimal places). - The oldest employee and his/her age.
Hints:
You could assume that the user will insert valid data and at least one employee. You could assume that the oldest employee is only one person. User could stop the program via entering the word "end" as an employee's name.
Sample Input and Output: In each line, insert an employee's name and his/her age To halt the program, insert "end" as an employee's name
Adam 30 Tom 41 Ted 45 Karl 30 end
The average age of all employees is 36.50.The oldest employee is Hisham whose age is 45
Write a Java program that reads a positive, non-zero integer as input and checks if the integer is deficient, perfect, or abundant.
A positive, non-zero integer, N, is said to be perfect if the sum of its positive proper divisors (i.e., the positive integers, other than N itself, that divide N exactly) is equal to the number itself. If this sum is less than N, the number is said to be deficient. If the sum is greater than N, the number is said to be abundant.For example, the number 6 is perfect, since 6 = 1 + 2 + 3, the number 8 is deficient, since 8 > 1 + 2 + 4, while the number 12 is abundant, since 12 < 1 + 2 + 3 + 4 + 6.
so i'm following a java tutorial from the book and it has a few challenge questions. and i'm stucked on one. i think i just don't understand what is it that its asking me. heres the question, Write a statement that reads a user's input integer into the defined variable, and a second statement that prints the integer. assuming scanner is given, and i checked my heading code is ok.
Scanner scnr = new Scanner(System.in); int userNum = 0; System.out.println("What is the product of 8 time 2"); userNum = scnr.nextInt();
I'm currently learning Java and have been set an assignment that requires me to do the following:
Write an application that reads in a line length followed by individual lines containing text. No input line will be longer than the read in line length. In the text lines each word will be separated by a single space. The lines of text to be reformatted and then output so that the output lines of text have straight left and right margins. The last printing character in each line will be at character position (line length). In the text output the character '.' is to be used to represent the space character.
I'm trying to take this task on, but I'm unsure as to what exactly I'm supposed to do with part of it. For one of the methods I need to "work out how many extra spaces will need to be added to make the line width characters long.", how would I go about doing this?
Write a program (TwoIntegers.java) that prompts the user to enter two positive integers and prints their sum (by addition), product (by multiplication), difference (by subtraction), quotient (by division), and remainder (by modulation). When the user enters 5 and 3, the output from your program should look exactly like the following:
Enter two positive integers: 5 3 The sum is 8. The product is 15. The difference is 2. The quotient is 1. The remainder is 2.
import java.util.Scanner; public class TwoIntegers { public static void main(String[] args) { System.out.println("Enter two positive integers: "); Scanner userInput = new Scanner("System.in"); int integer1 = userInput.nextInt(); int integer2 = userInput.nextInt();
I am working on a class project and I have to write the JUnit test for the GUI class ... what I did wrong ... Here is the code for the GUILauncher:
package edu.oakland.production; import java.awt.*; import javax.swing.*; public class GUILauncher{ public static void main(String[] args){ RetrieveWindow gui = new RetrieveWindow();
I'm going to be taking an object oriented paradigm using java during intersession in a few months. I'm trying to brush up on it a bit. The problem is. Write an application that displays the numbers 1 to 4 on the same line, with each pair of adjacent numbers separated by one space. Write the program using the following techniques:Use one system.out.printLn statement.Use four system.out.print statement.Use one system.out.printf statement.
This is what i have so far .
Java Code: public class Display { public static void main(String [] args) { System.out.print("1 "); System.out.print("2 "); System.out.print("3 "); System.out.print("4 "); System.out.println(" ");<----is that what that is supposed to look like, and where it goes? System.out.printf(" %s %s %s %s ");???? } } mh_sh_highlight_all('java');
i cant test this my console isn't working right, and i haven't finished my compiler install.
ABC is a company that designs and prints personal business cards. The company has asked you to write a Java application to display the layout of the information in a typical business card order. Data items in a typical business card include the customer's name, address, city, state, postcode, home phone number, and work phone number.
Write, compile, and test a Java class that displays these data items in a command window. Alternatively, you could also create it using a dialog box. Please include appropriate comments in your class.
Please named your class BusinessCard(LIM).java. (eq. BusinessCardLIM.java)
I am writing a program for my college class that does the following:
Reads a text file that consists of words from a-z. The content read from the file is displayed in the JTextArea, while the user can filter the search results based on what they input. For example, if the user enter's "a" then the JTextArea is updated with all words that start with the letter "a" only. Also the user can enter a substring or the whole word and the respective result will be only the words that match the user's input.
The Problem and question I have is what would be the best way to go about filtering a file of about 27,000 words based on user input. I tried using an arraylist but the problem is it took forever to update the JTextArea, which is not good. Also I am new to using JSwing so I may not be aware of a component that would make this easier.
Here is the code:
Note: the question lies within the actionPerformed method.
I'm very new to writing code (college freshman) and I need a code that prompts for and reads in the number of coins in one of the piles, as well as a String containing a single letter to indicate the type of coin in that pile: "P" for pennies, "N" for nickels, "D" for dimes, and "Q" for quarters. The program then computes the value of that pile of coins and prints it out. Here's what I have so far:
import java.util.Scanner; /** This program reads a student's final class average, and prints out the appropriate letter grade.. */ public class Coins { public static void main(String[] args) { // Define constants
I am trying to make a java code that reads in lines of text and returns the number of spaces in each line.I think i have made it but i can not compile it..
Here is my code:
class Mainh { public static void main( String args[] ) { System.out.print( "#Enter text : " ); String text = BIO.getString(); while ( ! text.equals( "END" ) )
convert or move standalone java thread application into Tomcat server container for accessing its JNDI services? Also is it possible to schedule this thread application in Tomcat server? is it possible to keep this app in tomcat as web application and schedule in window's scheduler.
I am new to work on JNLP program. I have created a SWING program, JNLP file when i deploy the ear file i am getting 404 error. Please find the steps in details.
1.Created a dynamic web project JWStartProject in eclipse
2.Create a HelloWorld.java class under default package.
import javax.swing.*; public class HelloWorld extends JFrame { private static final long serialVersionUID = 4968624166243565348L; private JLabel label = new JLabel("Hello Java Web START!"); public HelloWorld() { super("Jave Web Start Example"); this.setSize(350, 200); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE ); this.setLayout(null);
[Code] ....
Now I exported this project as JWStartProject.war contains following code.
Created Server in Websphere Admin console
Deployed this war file under the server and started.
I have added MIME types also.
I am unable to launch the application. I am getting 404 errors. May I know where I went wrong?
After the code is executed the array is supposed to contain 2,3,5,3,2. However, prime[4-0]= prime[i] and prime[4-1]= prime[i]... doesn't the loop terminate before it iterates a third time? Why are there five integers instead of only two?
import java.util.Arrays; import javax.swing.JOptionPane; public class Student { public static void main(String args[]) { String [] A =new String [4]; //krijon tabelen e emrave
[Code] ....
It Prints [firstname,secondname,thirdname,fourthname]
and [0,0,7,9]
The problem is that the first 2 integers of the second array are always 0 even if i put another grade like for example 6 or 7...
Our teacher asked to input the names and grades of the students using JOptionPane and then find the MINIMUM grade and how many times this grade is repeated...
Create a loop where you add the integers from 1 to 50.
public class Sum50 { public static void main(String[] args) { int sum = 0; int max = 50; for(int i = 0;i <= max; i++){ sum=sum+i; } System.out.println("Sum is " + sum); } }
I need to write a class in that uses the For loop and does the following things: asks user to input two integers, the second larger than the first. Next, use a for loop to sum the numbers between the two integers, including the original integer. For example: 5&8 would be 5+6+7+8 and lastly prints out the sum of this.
I have successfully been able to do the first part but when it comes to the For Loop I am a bit lost here is what I have so far
import java.util.Scanner; public class Question3 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Please enter an integer"); int num1 =sc.nextInt(); System.out.println("please enter a larger integer"); int num2=sc.nextInt(); int sum=0; for(int i=num1; i<=num2;i++); } }
I have this code running correctly in Eclipse all except that it seems no matter where I declare, highest, lowest, average they always seem to stay at "0". I have a feeling the location of the Initialization is not the error since I have tried moving it to inside differ loops.
Stipulations on writing this code are:
Note: You do not need to use array to save each input score for this lab. A Single loop to read in each grade, compare with the current highest grade, lowest grade, and calculate the running sum at the same time.
import java.util.Scanner;
/*Write a program that prompts the user to enter the total number of students first. *Then ask the user to input each student’s grade and use loop statements to read in each grade. *Check input grade to make sure 0<=grade<=100, if the user input any other number, print out warning message and ask the user to input a new grade. Display the highest score, the lowest score and the average. */
public class LoopStatements { // Main Method public static void main(String[] args) { // Initialize int grade = 0; // grade value
my code is below and i want to read only integers.BUT the text file is starting with text and it stops executing without reading the numbers.Also i want to add the 3 parameters of each line.
try{ File fl = new File("C:/Users/Mario/Desktop/testing.txt"); //BufferedReader rd = new BufferedReader(new FileReader(fl)); Scanner sc = new Scanner(fl).useDelimiter("s+"); LinkedList<Integer> temps = new LinkedList<>(); sc.useDelimiter(System.getProperty("line.separator")); while(sc.hasNext()){