Basically I have to enter 5 numbers that I put through a loop and they print the star * depending on the number.An example would be this 5:*****. However, my codes prints out 5:*; 5 times. How to correct my code
Java Code:
import java.util.Scanner;
public class IntegerOutput
{
public static void main( String args[] )
{
Scanner input = new Scanner( System.in );
we have been given a scenario to design a system in which we have to make the class diasgrams. however we have to use appropriate patterns that match the scenario.
I've looked over the concepts of Java programming, tested them in code and i understand most of them. I have a problem when i need to make harder programs , this might be because i dont know design patterns and algorithms.I'm curious what a entry level programmer needs to know to get a job in the field. Right now i was thinking i need to know:
1. The way all big concepts work and most of the keywords.
2. Design patterns.
3. Algorithms.
what i actually need to know for an entry level job and can you tell me which design patterns and algorithms are a must know for that first job. Considering i might have financial problems in the near future this is not a theoretical question, i really need to know what i need to learn in the next 2-3 months to get an entry level job down.
Here is an example of a GUI. Is it possible to make this kind of a thing using Java Swing? Is it possible to have a picture on the entire background of the JFrame, and then other Swing components like buttons, labels etc. sitting on it?Is it possible to have action listeners behind pictures? In other words, they will behave like buttons: the user clicks on them and they do something.
The idea I'd like to present, concerns the correction of "designer" drawings - those done by the design consultants - against "site/construction" drawings - them being used on site by the workers to build the project itself.
This is normally a laborious process, involving being sat at a desk with two large folders, checking each detail and measurement against the design drawing.What I'd like to present is an idea, where the co-ordinates of the design or "mother" drawing, are transferred into a usable Java program, and they could be then used to ensure correct dimensions have been applied by the the sub-contractors in their "construction" drawings.Like I said, this can normally be a process of days for a site engineer to check - process known as "QA, quality assurance".
Basically, I just need to make a presentation of having a genuine interest in Software Design and Development. It could be applied in a range of areas in terms of construction site application - checking drawings, writing up work orders, dig orders etc - but the principle of having the co-ordinates of the mother or "design" drawing scanned into an array in Java as a means to output those site drawings/orders etc, applies to each potential application.
So - in short - and not looking for crystal clear detail, just general pointers - what programs or methods could transfer a plethora of co-ordinates from a design program like Auto-Cad, to a Java program, where I assume I would then be using a program containing a complex series of loops to ensure the correctness of the derived "construction" drawings; derived from the "mother" or designer drawings, that is.
I am planning to develop an application that does the following:
1) Receiving an audio streaming from a shoutcast server 2) Decode and push it throught producer to a shared buffer 3) Share audio data to as many consumers are interested to this feed.
What is the best practive for doing this? I tried several things without success.
How can i do this in best way, i what to avoid infinite loop .....
The use case is i get value from use and query value from database,sometime use can send value which return null in database,i what to avoid those null value .....
There is some kind of issue here.in the gui it will ask you to give points in time (ms) it wants to click for you, although when for example i put in 3 at "How Much Clicks" it asks 4 times and then exits with an error.Here is the error:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 3 at relax.Relax.StartSetup(Relax.java:175) at relax.Relax$2.actionPerformed(Relax.java:78) at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source) at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source)
design a class to conduct a survey of three hospitals. you want to know how many sectors (eg operation, children, gastronomic) each hospitals have, and how many doctors there are in each sector.
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.
I have done this a few times but I want to make sure I am doing it correctly. In other words creating a clean understandable program. Instead of posting code I will just talk about this is my plan:
Create a model (getter and setters) Create a view (via swing) Create a controller (pass the model and view in the parameter)
Database DatabaseConnection: Use the singleton pattern
Database: Create an interface called Database with all the queries I will need (insert, delete etc) Create a class called DataBaseDAO and implement the interface database and get an instance of the DatabaseConnection.
Tying it all together:
In the controller should I use the "new" operator and create a new database class or extend the database class? I am thinking I should not do it in the controllers constructor but make a field if I use the "new" operator like:
private Database db = new Database(); Create a class called App Create a new Model Create a new View Pass the view and model into the controllers parameter.
Am I on the right track? Is this messy? Is there a better way of doing it?
I need selecting which design pattern to use in my case.
I am creating a list of objects "items" to be presented in a list for the user to choose from, all objects have a title and a check box. Some objects have additional textbox for user input, some objects have additional image for illustration, and some objects have additional textbox and image as well.
I read and saw online videos but not sure if my selection "Factory Design Pattern" is the best match.
I just started playing around with Java for awhile, but got caught up in a problem when using ArrayList.
CinemaAppMain public class CinemaAppMain { public static void main(String[] args) { new CinemaApp().start();
[Code]....
I am trying to get the movie name and theatre title from their ArrayList, and I know I need to go through the movie list & theatre list to find their name & title, and compare it with the user input and print out the result.
I use for(int i=0;i<movies.size();i++) to go through the the movie list, and I tried using for(int i=0;i<theatres.size();i++) to go through the theatre list. But when I printing multiple time with different user input value, it will show me strange result (screening have same movie name & theatre name, the else if statement is printed below the user input, user input is printed more than once after the first time).
Edit: I know its wrong for me to use nested for loop,if not, another solution is needed to get the item inside both of the list. (getting the "title" from movie list & "name" from theatre list)
I need to do a simple while loop pay calculator. I am very new and not sure what I need to do to put all the requirements in the new code from another code. Here is my code that doesn't work yet.
1.Place the wage calculation routines in a while loop. 2.Allow the user to input an individual's hours worked. 3.Accumulate the total regular hours worked, the overtime hours worked, the amount of the regular pay, the amount of overtime pay, and the total payroll, for all of the employees entered. 4.Allow the user to enter a zero (0) as the Boolean expression to end the loop. 5.When the loop ends print out all of the accumulated totals with appropriate labels, each on a separate line.
import java.util.Scanner; public class WhileLoopPayCalc { public static void main(String [] args) { final double REGULAR_HOURS = 40f; final double HOURLY_WAGE = 12.5f; final double OVERTIME = 1.5f; double wage = 0f;
The assignment is: A machine purchased for $28,000 is depreciated at a rate of $4,000 a year for seven years. Using a for loop, write and run a Java program that computes and display a depreciation table for seven years. The output should look like:
DEPRECIATION SCHEDULE ------------------------------------------------ YEAR DEPRECIATION END-OF-YEAR ACCUMULATED VALUE DEPRECIATION ---- ------------ ---------- ------------ 1 4000 24000 4000 2 4000 20000 8000 3 4000 16000 12000 (and so on until year reaches 7)
I did attempt it. I'm just extremely stuck and don't know how to move forward. My code is below:
import java.util.Scanner; public class Depreciation_for { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int number = 1;
The assignment is: A machine purchased for $28,000 is depreciated at a rate of $4,000 a year for seven years. Using a for loop, write and run a Java program that computes and display a depreciation table for seven years.
The output should look like:
DEPRECIATION SCHEDULE ------------------------------------------------ YEAR DEPRECIATION END-OF-YEAR ACCUMULATED VALUE DEPRECIATION ---- ------------ ---------- ------------ 1 4000 24000 4000 2 4000 20000 8000 3 4000 16000 12000 (and so on until year reaches 7)
I did attempt it. I'm just extremely stuck and don't know how to move forward. My code is below:
import java.util.Scanner; public class Depreciation_for { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int number = 1;
I was learning looping in Java and decided to try this code and then I encountered an endless loop of 2s. why is that? I believe this line count=count++ caused it.
class ForDemo{ public static void main(String []args){ int count; for(count=2;count<=5;count=count++) System.out.println("count is:"+count); System.out.println("Done!"); } }
I am completing the exercises in Java How To Program 8th Edition by Harvey and Paul Deitel.There are two optional exercises GUI and Graphics Case Study Exercises on page 141 Chapter 4.
I have to use loops and control statements to draw lines thereby creating two designs.I am trying to create the design on Fig. 4.20. The lines do not line up correctly.The lines should fan out from all corners. Individually, they look exactly like it should.
Example of one corner.
int width = getWidth(); int height = getHeight(); // upper-left corner int startX = 0; int startY = 0; int endX = 0;
[Code] ....
For the other corners I have different starting and ending positions.To draw upper-left corner I have a starting position of 0,0 and ending position of 0,height.I then move ending position up one vertical step and right one horizontal step. I repeat this fifteen times.
To draw upper-right corner I have a starting position of width,0 and ending position of width,height. I then move ending position up one vertical step and left one horizontal step.
To draw bottom-left corner I have a starting position of 0,height and ending position of 0,0. I then move ending position down one vertical step and right one horizontal step.
To draw bottom-right corner I have a starting position of width, height and ending position of width,0. I then move ending position down one vertical step and left one horizontal step.
For the second design Fig. 4.21 all my lines line up correctly no matter the direction I resize it. Both designs frame size is 250,250. Both designs are divided into fifteen steps.
I am trying to design properly a simple 1to50 game (yes, the one that is so popular among mobile apps), but as a web application that allows two player games. I tried to document myself on the technologies I could use and came to the decision that some kind of Java would be suitable. I know that HTML, HTML5, CSS, JavaScript are client side languages with what I can basically design the client application that runs on a web browser. I installed Tomcat web server, configured Java Servlet API, done some research on Servlets and JSP, but I still cannot really imagine how all of this can work. Servlets form the Controller, JSP files the Model? How can I make them communicate, how can Servlets "tell" JSP files what to dynamically generate? Can JSP files communicate with JavaScript? Is JavaScript even necessary?
I thought that this question is not basically about a specific thing regarding JSP or Servlets, more about design and general concept, that is why I put this question under beginning Java.
I was told to design a class named Rectangle to represent a rectangle.The class contains:
■ Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. ■ A no-arg constructor that creates a default rectangle. ■ A constructor that creates a rectangle with the specified width and height. ■ A method named getArea() that returns the area of this rectangle. ■ A method named getPerimeter() that returns the perimeter.
Draw the UML diagram for the class and then implement the class. Write a test program that creates two Rectangle objects one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area,and perimeter of each rectangle in this order.Here is my code for the Rectangle Class:
class Rectangle { double width; double height; public Rectangle() { width = 1; height = 1;
[code]....
The error that I am given when I compile the driver is as follows:constructor Rectangle in class Rectangle cannot be applied to given types; required: no arguments; found:int,int; reason: actual and formal argument lists differ in length.