Write a program that reads an integer and displays, using asterisks, a filled diamond of the given side length. For example, if the side length is 4 the program should display.
* *** ***** ******* ***** *** *
I have it where it displays the top half of the diamond. But i cannot figure out how to get it to draw the bottom half.
import java.util.*; public class E616 { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter number of rows. "); int N=input.nextInt();
I wrote this (for the variable name, this is just a small part of my program and I'm trying to get the pattern right so I didn't mind my variables at the moment):
Java Code:
public class NewFile{ public static void main(String []args){ int k = 0; for (int i=1 ; i<=5 ; i++) { { for (int h=2 ; h >= i ; h--)
I realize I should divide the code into a lower and upper triangle using two loops. However, I don't know how to break the first part. I did find the "trend" but I don't see how to implement it.
My code below creates the 2 files successfully, but it is not able to write the sample data into the newly created file. I can't figure out the reason why.
Another strange thing is that when I tried inserting System.out.println calls for debugging, nothing prints out.
I first time tried Java web service sample example using eclipse with axis2. First i wrote the provider class. Then by clicking create Web Service from the provider class It will show the following error "IWAB0014E Unexpected exception occurred." I have attached the screenshot for reference.
Nearly all of hte sample Java Applet is pre-made by the teacher. I'm running into the issue where, if I use the string arithmetic inverse method provided by the textbook, it refuses to recognize variables such as s1, s2, and i. So I'm now trying to use stringbuilder, and running into a similar issue. It doesn't recognize hte symbol "buffer". Under the "else if ( e.getSource() == inverseStr ) {" is where my code starts. The "Your Code Here" was put there by the teacher, and I'm just using it as an easy way to create blank lines if I delete a method that isn't working for me in the above section.
import javax.swing. * ; import java.awt. * ; import java.awt.event. * ; public class HW07 extends JApplet { public void init() { setSize( 400, 300 ); add( new MyGUI() );
[code]....
When I launch the applet in TextPad, there will be an Inverse button, and when I click that, it should reverse the word provided in the applet window, and show it in the inverse there. I had the StringBuilder working once, but it showed its result in a separate command prompt.
my idea is auto recognize when i put image like survey and that survey has shape box and it random area location and some shape box also character and number and can generated data that recognize in csv file.
Write a java program that uses a While loop and persistent output to count down from 33 to 0 by threes, and put each value on a separate line, also do this in for loop.
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)
Write a java program to read the time intervals (HH:MM) and to compare system time if the system time between your time intervals print correct time and exit else try again to repeat the same thing. By using StringToknizer class.
I have an excel spreadsheet, with a specific filename and location which doesn't change (e.g. C:/workbook.xls)What I would like to do is have a window open when I open an .exe file, and in this window is a bunch of check boxes, text areas and drop down boxes (I can implement these, that's about my level of JAVA)
Then, when I click on a button in this window (for example, a button which says "Save"), the data from all these boxes and menus etc. goes into specific cells in the excel spreadsheet. Or if certain values are selected from a drop down menu, then a bunch of cells are empty.
1. The words remain in their places but the letters are reversed. Eg I love you becomes Ievol uoy 2. The words are also reversed. Eg I love you becomes uoy evol IWrite a program that use the java String class methods.
I was working on this project, and I have everything working, except that it doesn't change the colors of the shapes in the other window. Here's the code to see what I'm doing wrong:
Java Code:
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class JDemo { //Global Variables static Color color0 = Color.blue; //sets the value in the color0 variable to the method Color.blue . static Color color1 = Color.red; //Sets the value in the color1 variable to the method Color.red .
[Code] ....
The button0 is supposed to switch the color in window1, and button1 is supposed to switch the color in window0.
I am trying to write a java program that asks the user for a list of names (one per line) until the user enters a blank line. At that point the program should print out the list of names entered, where each name is listed only once (i.e., uniquely) no matter how many times the user entered the name in the program. I am supposed to use an ArrayList for this problem.
My idea for a solution is to create an ArrayList<String>, read each name, i.e., line, entered and then to see if that name is already in the ArrayList. I created a for loop to check each element in the ArrayList but when I try to assign an element to a string variable I get the error "Type mismatch: cannot convert from Object to String". Not sure why that is happening because the ArrayList is defined as a String list.
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.
Ex. If I type 5943, the program will say mill = 5 hun = 9 ten = 4 uni = 3
get the picture I had to translate the decimal value names from a different language.
This is what I have tried...,
Java Code:
import java.util.Scanner;//Permite el uso de leer el teclado del usuario public class DeterminarValorDecimal//Nombra el documento { public static void main(String [] args)//Podemos ver la clase {
[Code].....
But what this does is I have to enter the single digits one by one. I want to be able to type the whole number. Is there a method that reads the length of the whole number and lets me classify each digit so I can do what I want to do?
Write a Java program that calculates the area and volume of a cube, sphere, cylinder, and regular tetrahedron. Your program should obtain the necessary input for each of the objects from the console and output the input, area, and volume of the object. Use appropriate messages to guide the user of your program.
Here what i did, i am not sure if this is what the assignment want, but this is the best method i could come up with
//Khang Le import java.util.Scanner; public class InputAreaVolume { public static void main(String[] args) {
I want to write a java program which displays to get the GPA of a student as a keyboard input. Then display the class of the degree according to the following criteria using a switch-case statement (if-else statements cannot be used). If the user insert an invalid gpa you should display a message Invalid GPA.
gpa ≥ 3.50 First Class Hons 3.49 ≥ gpa ≥ 3.00 Upper Second Class Hons 2.99 ≥ gpa ≥ 2.50 Lower Second Class Hons 2.49 ≥ gpa ≥ 2.00 Pass 2.00 ≥ gpa Fail
Here is my code:
import java.io.*; public class q7 { public static void main(String[] args) { InputStreamReader ISR=new InputStreamReader(System.in); BufferedReader BR=new BufferedReader(ISR);
[code]...
.But when I use Command console to run this it says: 1111.jpg. I also wanna know is there another way to do this with switch- case statements.
Write a java program to store employee information in a linked list, the program should implement the following functions:
The program should display the list of functions, and ask the user to enter the number of function that he/she wants to do, then perform the function as it is required in the previous table.
import java.util.*; public class Employee { Scanner in = new Scanner(System.in); String Name; String Address; String Department; int ID; int Salary;
[code]....
this is my out put
Please choose a number: 1-Add a new employee 2-Update employee's info 3-Remove employee's info 4-Exit 1 Enter name: Enter address: 2 Enter department: 3 Enter ID: 4 Enter salary:
now:
1- why are not my adding coming out in the output only the Enter name & Enter address ??
2- how can I add names and ID's and information to test that program
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.
I am supposed to Write a program that prints a shape similar to the following shape. Maximize use of loops and minimize use of print statements.
.....* ....** ...*** ..**** ...*** ....** .....*
(without the "...")(i couldn't get it to stay in shape)
This is what i got so far:
Java Code: package assignment7;
public class Exercise3 { public static void main (String[] args) { for (int count =0; count < 4; count++) { for (int j=0; j < count+1; j++) [Code] ....