How To Write Program Without Using Control Structures
Feb 24, 2015How to Write Program with out using control structures
IMG_4216.JPG
How to Write Program with out using control structures
IMG_4216.JPG
I know nothing about algorithms and data structures.Is there any good books where I can start learning it.Should I also learn advanced mathematics?
View Replies View RelatedI'm finishing my data structures class and looking for internships and trying to prepare myself for real world application of things I've learned. I'm trying to figure out what sort of project I can start or start over winter break that would use the new data structures I've learned (BSTs, Heaps, Hash Tables, etc). We have been implementing these from scratch but would I be using a library for these on the job? If so, should I implement them that way instead? I have a registrar project from my first data structures class where I used a linked list and then an array list to take care of the different students, classes, and instructors. Maybe I should clean that up and just use that?
how these data structures can be used in non-trivial situations and why I should use one over another. I just don't know a good place to start.
how to create new nodes with this values below and insert them in the following order.
55, 2, 76, 2 , 9, 1, 90, 43, 5, 23, 86, 3, 321, 4, 32, 66, 99, 12, 21
I have one Insert method One traversal method, with a post-order( I don't know if I need to use pre-order, I'm trying to use a very poor hash function ℎ(xx)= √xx xKK mod 2 where xx is 2012559 and KK=3.14. If ℎ(xx) = 0, my traversal method is pre-order, and if ℎ(xx) = 1 my traversal will be post-order.I have 4 separated classes, Tree.java, Node.java, Test.java and traversalType.java
package BST;
public class Node {
int data;
Node leftChild;
Node rightChild;
public Node(){
[code]....
I have a java query like this
query ="Select major_career.Major_Title, career.ISCOTitle,career.FS.... " //only partial,
// I swear the query is correct
resultSet = statement.executeQuery(query); //this executes it
relArr = new ArrayList<String>(); //don't worry it is intialized
In the code below I tried to store the resultset components into the arraylist
int j = 1;
while (resultSet.next()) {
while(j<=numberOfColumns){
relArr.add(resultSet.getObject(j).toString());
j++;
}
} // end while
I am not sure whether the arraylist is able to store the result set because when i try to display it like show below it only shows some rows and only the first column
Iterator it = relArr.iterator();
while (it.hasNext())
{
System.out.println(it.next());
I want to manipulate the resultset results in my program by copying the resultset values to other datastructures.
how to create new nodes with this values below and insert them in the following order.
55, 2, 76, 2 , 9, 1, 90, 43, 5, 23, 86, 3, 321, 4, 32, 66, 99, 12, 21
I have one Insert method One traversal method, with a post-order( I don't know if I need to use pre-order, I'm trying to use a very poor hash function ℎ(xx)= √xx xKK mod 2 where xx is 2012559 and KK=3.14. If ℎ(xx) = 0, my traversal method is pre-order, and if ℎ(xx) = 1 my traversal will be post-order.
I have 4 separated classes, Tree.java, Node.java, Test.java and traversalType.java
package BST;
public class Node {
int data;
Node leftChild;
Node rightChild;
public Node(){
[code]....
Every type of controllable object in my game is a type of Entity, and so extends Entity. This is broken down into Ship(s) and Structure(s). But I have different types of structures as well. The problem is that I use an ArrayList<Structure> to store all of a team's structures, but I need to be able to loop through that, and still be able to reference the subclasses of those structures.
For example, I have a JumpGate, which extends Structure. I need to be able to reference a particular JumpGate - as a JumpGate - and not as a Structure. However, the way that I cycle through all of the different types of structures is with an ArrayList<Structure>. I could get around this by having an ArrayList<JumpGate>, however, I would then need a seperate ArrayList for every type of Structure, which would get messy.
How do i write a program using textEdit? I can't even get the examples to open?
View Replies View RelatedMy program successfully reads a file, reports back what it finds and creates an output file. However, I cannot get it to write to the output file, it is always blank!
Here's my code:
import java.util.Scanner;
import java.io.*;
public class Ex19
{
public static void main (String [] args)
{
//Variables
[code]....
I have to write a program that find the sum of two numbers 62 and 99 and stores them in a variable named total. However, I have one error that I just can't get rid of and can't tell what it is. I'm using jGrasp and here's what it says:
Programming Challenge #5.java:14: error: class SumofTwoNumbs is public, should be declared in a file named SumofTwoNumbs.java
public class SumofTwoNumbs {
^
1 error
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
and here: is my code:
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
// This program has variable of several of the integer types.
public class SumofTwoNumbs {
public static void main(String[] args) {
[code]....
Write a program called GeometricMean that prompts the user to
1.Enter the number of values (total number of instances) that should be processed
2.A set of values to be processed (in a while loop)and then calculate the geometric mean of the values entered. You should use a while loop to perform the multiplication part of the calculating the geometric mean. The program should output the initial data and the labeled geometric mean. Consider printf, and DecimalFormat.
My Program:
import java.util.Scanner;
public class GeometricMean{
public static void main(String[] args) {
Scanner keyboard= new Scanner(System.in);
[code]...
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.
View Replies View RelatedI'm trying to use graphics for my programs and here I'm trying to write a program that searches through files for text received from a JTextField. However, it does not seem to be working as my message is not displayed when text is found...
I used applet. Here are the functions:
JTextField jtf;
JFrame jf;
public void init()
[Code].....
I'm rather new to programming and I'm trying to make a gui program that will allow the user to create text files. They will be prompted to enter what they'd like to save their file as and then they will be allowed to input text to that file . They will also be allowed to open their files to modify or view its contents. So to start things off, I'm making a prototype if you will.. I've been able to save to a file the problem occurs when I try to read/display it.
Main Class:
public class MainActivity {
public static void main(String[] args) {
// Access to other classes
WriteFile writer = new WriteFile();
ReadFile reader = new ReadFile();
[Code] ....
I have a question. How to write a progamme which compensates an average if it is less than a 10/20. I use eclipse and database HSQLDB. I have a table with notes. After the compensates, I must change the note in my database.
I have three notes
12, 11, 5
The average is 12+11+5/3=9,33
I take the lowest note: 5
12+11+x/3 = 10
12+11+x/3 = 30/3
x=30-23
x=7
The new average is 12+11+7/3=10
My code:
public class Fibonacci {
/**
* @param args
*/
public static void main(String[] args) {
int f[]=new int[100];
for(int j=0; j<100;j++){
f[j]=j;
[Code] ....
How can I improve my code?
As per requirement i need a dynamic multi map in my application. How to write a method to create the dynamically map.
View Replies View RelatedWrite a program named QuadraticTable.java that takes three double arguments and two int arguments (in that order) from the command line. The three doubles will represent a, b, and c from the quadratic formula.
If the discriminant is non-negative, find and print the solutions to the quadratic equation. (The plus/minus sign in the quadratic formula indicates that you would separately perform both operations). Otherwise print "no real solutions".
Then using the last two int arguments as x_min and x_max, print a table of x and ax
2 + bx + c
values using the a, b, and c read in as command line arguments.
Sample output: (command line arguments were 1 0 2 -3 3)
1x^2 + 0x + 2 has no real solutions.
X 1x^2 + 0x + 2
-3 11
-2 6
-1 2
0 2
1 3
2 6
3 11
I am trying to write a program that takes two numbers and multiplies them. I got this idea from this running conversion program
import java.util.Scanner;
public class Convert
{
public static void main (String [] args)
{
Scanner reader = new Scanner (System.in);
double farenheit;
double celsius;
[code]...
i am getting a cant find symbol for the output = (alpha*beta) line..Also, am I using the reader object correctly ? hould I create two reader objects as there are 2 inputs needed?
having some trouble doing this. Here are the requirements:
1)Write a program using loop and break to calculate the value of PI.
2)You can use the following equation to calculate PI. PI=4/1-4/3+4/5-4/7+4/9-4/11+4/13 etc.. The program shouldn't loop until the criteria is satisfied.
3)The criteria is the value of PI you get is very close to the “real” value (3.1415926), meaning that their difference
should be smaller than a very small numeric number, e.g., 0.0001).
4)The control structures you may need for this program are loop, if-else, and unlabeled break.
5)The output should have the format: for each iteration, it has iteration number and the corresponding value of PI until that
iteration. The last line would be the final value of PI.
Here is my code so far:
package ids;
public class IDS {
public static void main(String[] args) {
double pi = 0;
for(int i=1; i<=100000; i++){
if ((i%2)==0){
pi+=(4/(2*i-1));
[code]...
Design, write a java program to input 7 integers and, for each integer, calculate and display its square and cube.
View Replies View RelatedI want an app that I can use to save the name, address, item sold, subject discussed and date that I visited someone - in a job similar to a sales rep. I would like to be able to choose how to sort the info so that if I sort by date I can see who hasn't been visited for the longest and start there. If I think of someone's name then of course I want to sort by name.
One of my friends says he works with "php"[? I'm still learning these terms] and everything happens online. I would like it to be an android app so it can be done without an internet connection ....
1. Write a program that displays the following table (note that 1 mile is 1.609 kilometer):
Miles Kilometers
1 1.609
2 3.218
3 4.827
...
...
9 14.481
10 16.090
Note: use for loop and printf() to format your output
public class MilesandKilometers {
public static void main(String[] args) {
System.out.println("Miles Kilometers");
int miles = 1
;
for (int i = 1; i <= 10; miles++, i++) {
System.out.println(miles + " " + miles * 1.609);
}
}
}
how to make it like the instruction said " use for loop and printf() to format your output".
I have an assignment where I'm supposed to write a program where the user inputs a month between 1-12 and then the right amount number in every month. I've tweaked the code a bunch of times, but I keep getting this error message:
insert "}" to complete StatementKALENDER_3.java
insert "}" to complete BlockKALENDER_3.java
The code:
import java.util.*;
import java.util.Scanner;
public class KALENDER_3
}
public static void main(String[] args){
Scanner scanner = new Scanner (System.in);
System.out.print("Skriv ett manadsnummer: ");
[code].....
I think I have just forgot to put in a few { } symbols, maybe an open 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)
[code]....
write a program to determine the sum of the following harmonic series for a given value of n:1+1/2+1/3+.............................+1/n the value of n should be given interactively through the keyboard.
View Replies View Related