Programming project - Reversed array
I'm having a little trouble with this programming project. What I have to do:
"Write a program named ReverseNumbers that prompts the user to enter 10 numbers, then writes the numbers in reverse order:
Enter 10 numbers: 34 82 49 102 7 94 23 11 50 31
In reverse order: 31 50 11 23 94 7 102 49 82 34
Hint: Store the numbers in an array, starting at position 0. When printing the numbers, visit the elements of the array in reverse order."
Here's what I have so far:
import jpb.*;
public class ReverseNumbers {
public static void main(String[] args) {
int[] reverse = new int [10];
int num;
int sum = 0;
int sum2 = 0;
int num1;
for(num = 0; num < reverse.length; num++) {
SimpleIO.prompt ("Enter ten numbers: ");
String x=SimpleIO.readLine();
reverse [num] = Integer.parseInt(x);
for(num = 9; num >= 0; num--) {
System.out.print( " " + reverse [num] );
}
warnerja wrote:
Roridge wrote:
Herko_ter_Horst wrote:
Roridge wrote:
You could delimit your input entry with a comma and then split on the input String to get your integers. e.g. "1,2,3,4,5,6,7,8,9,10"Right, because comma's are so much better than spaces...Yeah, well at least I Suggested something... you are so Elitist!I could have suggested that the OP bake a cake, but that would have helped about as much as you did.
You are so Noobist!What is the deal with you two, are you like two lovers sitting next to each other determined to prove your Elite status?
Similar Messages
-
I get the following error after the installation and configuration window of MS Project: "There is not enough memory to complete the operation. To free up available memory, close programs, projects, or windows you aren't using, and then try again."
It happens both with MS Project 2010 and 2013 on a Windows 7 desktop.
I tried installing / uninstalling Office 2010, MS Project, tried installing 32 and then 64 bit versions, clean up, disk error checker, startup changes (msconfig), anti virus, running as Windows 7 and then Windows XP compatible mode.
Nothing helps. I see this issue reported as early as 2007 version of MS projects on Microsoft forums, but I do not see any solution anywhere. Any suggestions on how to fix the issue without having to reformat hard drive? Every other application, including
all other Office programs work seamlessly.
I also tried Microsoft support, after an hour and a half of basically doing what I did before, I was told I have to pay 99$ for "premium" support, so someone can look at this bug.
I have 16 Gb RAM and more than 200Gb or hard drive free, so actual memory is not the problem.This issue was originally reported with MS Project 2007 and keeps popping up since.
A quick Google search provides more than 200K pages of results of this issue:
https://www.google.ca/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=There+is+not+enough+memory+to+complete+the+operation.+To+free+up+available+memory%2C+close+programs%2C+projects%2C+or+windows+you+aren't+using%2C+and+then+try+again.
And 193K results on Bing:
http://www.bing.com/search?q=There+is+not+enough+memory+to+complete+the+operation.+To+free+up+available+memory%2C+close+programs%2C+projects%2C+or+windows+you+aren%27t+using%2C+and+then+try+again.&go=Submit&qs=n&form=QBLH&pq=there+is+not+enough+memory+to+complete+the+operation.+to+free+up+available+memory%2C+close+programs%2C+projects%2C+or+windows+you+aren%27t+using%2C+and+then+try+again.&sc=0-0&sp=-1&sk=&cvid=4cb023c1fbd94ec2bba9821b095f21f2
Computer was defragged already. I run more tests, and specifically when MS Projects tries to run, it tries to take all memory, more than 300Gb, on the computer. (DropBox was running at the same time, and warned that there were no space. As soon as MS Project
stopped attempting to configure itself, everything came back to normal and the available space became available again.)
Looking through older forum posts, looks like this application tries to take "unlimited" amount of memory. Some registry fixes are mentioned potentially, but I was not able to apply them.
Since everything else works, this is a MS Project bug reported by multiple users on various versions of Windows, including Vista and 7, so please provide a fix and not 'not a know bug' lie. All the premium support will say, is to format the hard drive, unless
they have a patch or a registry edit solution. If the latter is true, since the issue exists for multiple years, it should have been already been provided to users.
Also, I am not running a SQL server, or any server, this is an installation on a local machine. -
How to reverse array display order?
Is there a way to reverse the way labview displays array data? When using a boolean array I would like the LSB to be on the right side.
I know that you can use the reverse array function, but that changes the actual data. I would rather just change how the data is displayed. Also I have quite a few and don't want to have to add that to all of them.
ThanksIt should be fairly trivial to add a reverse array before displaying the data. Keep in mind, when you display the data on the Front Panel, you can keep a parallel branch wire on the Block Diagram that is not affected by the Reverse Array.
Also, if you are displaying many of these arrays, perhaps you could use a 2D array on the Front Panel to show all bitmaps at once? Or, a 1D array that contains a cluster of the Boolean array if the Boolean arrays are ragged/jagged. Using this method would be scalable, meaning you would need only 1 Reverse Array for N arrays you want to display.
And smercurio_fc is right about the XControl being able to display a reversed array. But if you're not willing to drop Reverse Array in a few places, you're probably not willing to bite off the non-trivial task of creating an XControl (there's a moderate learning curve for getting the hang of creating a good XControl).
a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;} -
Java Software Solutions book programming projects
hey. if any of you have heard of this book you know that theres programming projects at the end of each chapter. if any of you might know a website that has solutions to these projects, could you please post a link for me. it would really help a lot. thanks
I have no delusion of the reality in programming. However, one has to acknowledge that some programming requirements are more concretely specified than others. I have done programming exercises in C++ (quite sometime ago and in class) that are defined in few pages. Many programming exercises in the book I mentioned are given just only in a few sentences to a page. There are also programming exercises that are defined in a way that the correctness of a solution can be verified more easily.
I am a novice in Java and have not done any program for quite some time, and I am learning the language alone. I want to ask an experienced Java programmer such as you that if there are better sources available for me to get some programming experience other than the programming exercises available in this book. Is there such a resource available? Could you point me to one?
Please don't take this personally. I am just frustrated. -
Programming project: does this code look clean enough to turn in?
Hi, i was just wanting to know people's opinion on the format of my classes below, i haven't done much java programming and I just want to make sure that this program is easily understood. I will not be able to respond, because I have to wake up in 3 hours for school. So thanks in advance, I will be reading this tomorrow, to see your suggestions, thank you.
here is the scholar class, it is the class that i made to create a scholar(student object) that will be applying for a scholarship and the grades are entered in the ScholarTester class.
I could've done things differently and easier but the professor strictly called for it to be exactly as he stated. I came up with a better, less tedious way, but i couldn't use it. My way was to create a method to randomly generate grades and values to determine the major, but my prof. saw it and made me implement everything in ScholarTester. Also neither of the students will receive the scholarship, that will be determined in project 2 my professor said.
package project1;
import java.util.*;
* @author Kevin
public class Scholar implements Comparable {
// private variables
private String fullName;
private double gradePointAverage;
private int essayScore;
private int creditHours;
private boolean scienceMajor;
private double totalScore;
// constructor for a Scholar object
public Scholar(String myFullName, double myGradePointAverage, int myEssayScore,
int myCreditHours, boolean isScienceMajor){
this.fullName = myFullName;
this.gradePointAverage = myGradePointAverage;
this.essayScore = myEssayScore;
this.creditHours = myCreditHours;
this.scienceMajor = isScienceMajor;
// returns a Scholar object's fullname
public String getFullName(){
return fullName;
// returns a Scholar object's gpa
public double getGradePointAverage(){
return gradePointAverage;
// returns a Scholar object's essay score
public int getEssayScore(){
return essayScore;
/// returns a Scholar object's credit hours
public int getCreditHours(){
return creditHours;
// retruns if a Scholar object is a science major or not
public boolean getScienceMajor(){
return scienceMajor;
// sets a Scholar object's full name
public String setFullName(String lastName, String firstName){
fullName = lastName + ", " + firstName;
return fullName;
// sets a Scholar object's gpa
public double setGradePointAverage(double a){
gradePointAverage = a;
return gradePointAverage;
// sets a Scholar object's gpa
public int setEssayScore(int a){
essayScore = a;
return essayScore;
// sets a Scholar object's credit hours
public int setCreditHours(int a){
creditHours = a;
return creditHours;
// sets a Scholar's major to a science major or not a science major
public boolean setScienceMajor(boolean a){
scienceMajor = a;
return scienceMajor;
// calculates a Scholar object's score
public double getScore(){
totalScore = (gradePointAverage*5) + essayScore;
if (scienceMajor == true)
totalScore += .5;
if (creditHours >= 60 && creditHours <90)
totalScore += .5;
else if (creditHours >= 90)
totalScore += .75;
return totalScore;
// compares two scholar objects.
public int compareTo(Object obj){
Scholar otherObj = (Scholar)obj;
double result = getScore() - otherObj.getScore();
if (result > 0)
return 1;
else if (result < 0)
return -1;
return 0;
// returns the highest scoring of two Scholar objects
public static Scholar max(Scholar s1, Scholar s2){
if (s1.getScore() > s2.getScore())
System.out.println(s1.getFullName() + " scored higher than " +
s2.getFullName() + ".\n");
else
System.out.println(s2.getFullName() + " scored higher than " +
s1.getFullName() + ".\n");
return null;
// returns the highest of 3 student objects
public static Scholar max(Scholar s1, Scholar s2, Scholar s3){
if (s1.getScore() > s2.getScore() && s1.getScore() > s3.getScore())
System.out.println(s1.getFullName() + " scored the highest" +
" out of all three students.");
else if (s2.getScore() > s1.getScore() && s2.getScore() > s3.getScore())
System.out.println(s2.getFullName() + " scored the highest" +
" out of all three students.");
else if (s3.getScore() > s2.getScore() && s3.getScore() > s1.getScore())
System.out.println(s3.getFullName() + " scored the highest" +
" out of the three students.");
return null;
// toString method for a Scholar object
public String toString(){
return "Student name: " + fullName + " -" + " Grade Point Average: "
+ gradePointAverage + ". " + "Essay Score: " + essayScore + "."
+ " Credit Hours: " + creditHours + ". " + " Science major: "
+ scienceMajor + ".";
}here's the ScholarTester class:
package project1;
import java.util.*;
* This program creates Scholar objects that are applying for a scholarship
* @author Kevin
public class ScholarTester {
public static void main(String [] args){
System.out.println("This program was written by Kevin Brown. \n");
System.out.println("--------Part 1--------\n");
// attributes for a scholar object named abraham
double abrahamGpa;
int abrahamEssayScore;
int abrahamCreditHours;
int scienceMajorValueAbraham;
boolean abrahamIsScienceMajor;
// random numbers used for each scholar object.
Random doubleGpa = new Random();
Random intGpa = new Random();
Random essayScore = new Random();
Random creditHours = new Random();
Random scienceMajor = new Random();
// randomly creates abraham's statistics
abrahamGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
abrahamEssayScore = essayScore.nextInt(6);
abrahamCreditHours = creditHours.nextInt(121);
scienceMajorValueAbraham = scienceMajor.nextInt(2);
if (scienceMajorValueAbraham == 0)
abrahamIsScienceMajor = true;
else
abrahamIsScienceMajor = false;
Scholar abraham = new Scholar("Lincoln, Abraham", abrahamGpa,
abrahamEssayScore, abrahamCreditHours,
abrahamIsScienceMajor);
System.out.println(abraham);
double georgeGpa;
int georgeEssayScore;
int georgeCreditHours;
int scienceMajorValueGeorge;
boolean georgeIsScienceMajor;
// randomly creates george's statistics
georgeGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
georgeEssayScore = essayScore.nextInt(6);
georgeCreditHours = creditHours.nextInt(131);
scienceMajorValueGeorge = scienceMajor.nextInt(2);
if (scienceMajorValueGeorge == 0)
georgeIsScienceMajor = true;
else
georgeIsScienceMajor = false;
// new scholar object is created from the existing attributes
Scholar george = new Scholar("Bush, George", georgeGpa, georgeEssayScore,
georgeCreditHours, georgeIsScienceMajor);
System.out.println(george + "\n");
System.out.println("--------Part 2--------\n");
System.out.println(abraham.getFullName() + " scored " + abraham.getScore() + ".");
System.out.println(george.getFullName() + " scored " + george.getScore() + ".\n");
System.out.println("--------Part 3--------\n");
/* comparing george bush and abraham lincoln's scores and printing them out to
show that the compareTo method is working*/
System.out.println(abraham.getFullName() + " scored "
+ abraham.getScore() + ".");
System.out.println(george.getFullName() + " scored "
+ george.getScore() + ".\n");
if(abraham.compareTo(george) == 1)
System.out.println(abraham.getFullName() + " scored higher than " +
george.getFullName() + ".\n");
else
System.out.println(george.getFullName() + " scored higher than " +
abraham.getFullName() + ".\n");
System.out.println("--------Part 4--------\n");
// prints out scores to show proof that the Scholar.max method is working right.
System.out.println(abraham.getFullName() + " scored "
+ abraham.getScore() + ".");
System.out.println(george.getFullName() + " scored "
+ george.getScore() + ".\n");
Scholar.max(abraham, george); // maximum score between abraham and george.
// variables for a scholar object named thomas.
double thomasGpa;
int thomasEssayScore;
int thomasCreditHours;
int scienceMajorValueThomas;
boolean thomasIsScienceMajor;
// randomly creates thomas' statistics
thomasGpa = doubleGpa.nextDouble() + intGpa.nextInt(4);
thomasEssayScore = essayScore.nextInt(6);
thomasCreditHours = creditHours.nextInt(131);
scienceMajorValueThomas = scienceMajor.nextInt(2);
if (scienceMajorValueThomas == 0)
thomasIsScienceMajor = true;
else
thomasIsScienceMajor = false;
// new scholar object created from existing attributes
Scholar thomas = new Scholar("Jefferson, Thomas", thomasGpa, thomasEssayScore,
thomasCreditHours, thomasIsScienceMajor);
System.out.println("New student added - " + thomas + "\n");
// returns all 3 students scores to show proof that the Scholar.max method is working right
System.out.println(thomas.getFullName() + " scored " + thomas.getScore());
System.out.println(abraham.getFullName() + " scored " + abraham.getScore());
System.out.println(george.getFullName() + " scored " + george.getScore() + "\n");
// highest score of all three scholars
Scholar.max(abraham, george, thomas);
}Thanks for reading this long and boring project.On comments: don't include a comment that just repeats syntax:
// constructor for a Scholar object
public Scholar(String myFullName, ...Anyone knowing Java syntax doesn't need that comment and gains nothing
from its presence, and anyone not knowing Java syntax shouldn't be reading
a listing.
On parameter names: a isn't very imaginative or prescriptive. (See next code.)
On setters returning the argument:
public int setCreditHours(int creditHours ){
this.creditHours = creditHours ;
return creditHours;
}1. Most people keep it simple and use a void return type.
2, The next most common convention is to return this:
public Scholar setCreditHours(int creditHours){
this.creditHours = creditHours ;
return this;
}Then you can chain calls, which is occasionally useful:
scholar.setCreditHours(4).setEssayScore(2);3. If you insist on returning the argument, note that this is a one-liner:
public in setCreditHours(int creditHours){
return this.creditHours = creditHours ;
} -
Revenue Hard Limit for Program Projects Funded by a Single Agreement
Hello All
We have the following Scenario
1) Project A and B are Liked to each other using Program functionality or using Project-Sub Project Functionality.
2) We have one agreement of USD 100,000 funding both projects are funded in the way explained below
Project Funding
Project A 40000
Project B 60000
Is there a way that can we can ensure that revenue hard limit is ensured at the Program level instead of the Project level?
For example
Given Project B has recognized revenue of 30000 USD can Project A recognize Revenue of 70000 as the total agreement is 100000 USD. Means Project A can consume funds allocated to Project B as these projects are interlinked. So that it is ensure that the total revenue recognized by both these projects is not more than 1,00,000 USD.
I am aware of manual reallocation Process of Funds, but is there a automatic way thru standard functionality.
Regards
DR
Edited by: 933993 on Jan 13, 2013 8:31 AMHi
No automatic solution using standard functionality.
You can set up the agreement with no hard limit, and develop a validation within a billing extension.
Dina -
Help with my Project - Includes Arrays, Inheritance and Polymorphism
COMP 1900 CS1: Introduction to Programming
Programming Assignment 4
Objectives:
* To work with superclasses and subclasses
* To work with an abstract class
* To gain experience working with an array of objects
Requirements:
* Understanding of arrays (Sections 7.1-7.3)
* Understanding of inheritance (Chapter 8)
* Understanding of polymorphism (Sections 9.1-9.2)
Assignment:
Write a Java application for a company payroll that has three different types of employees: secretary, junior salesman and senior salesman.
* Design an employee superclass that contains an instance variable for the employee name. In addition, there should be an (abstract) method to compute the yearly bonus that employees receive in the month of December.
* Design subclasses for each type of employee. The secretary subclass should have two instance variables: one corresponding to the initial year of employment and the other representing the salary. The junior salesman class has instance variables for base salary, total sales, and commission rate. The senior salesman class has one instance variable representing the total sales.
* Design get and set methods for each class. Each class should also have a toString method.
* Design a computeCommission method for each of the salesman classes as follows:
o For a junior salesman, the commission rate is set.
o For a senior salesman, the commission rate is variable based on total sales.
For sales < $10,000,000: the commission rate is 0.1%;
For sales between 10 and 25 million inclusive, the commission rate is .2%;
For sales over 25 million, the commission rate is .25%.
* Design a computeBonus method for all employee classes as follows:
o For secretarial staff, bonuses are dependent on the number of years that an employee has worked for the company. If an employee has worked less than 5 years, the bonus is $50; for 5 to 10 years, inclusive, the bonus is $75; for over 10 years, the bonus is $100.
o For junior salesman, the bonus is .01% times the sum of the yearly salary and the total commission for the year.
o For senior salesman, the bonus is .025% of the total sales.
* Design a class EmployeePayroll that has an instance variable that is an array of Employee objects.
* Design methods addEmployee and toString.
* Design a method that computes the average of all employee bonuses.
* Design the method that counts how many employees received a bonus bigger than the number sent in as parameter.
* Design a method that finds the employee that has earned the biggest bonus.
* Design a class TestEmployeePayroll that creates an array with 9 Employee objects (3 of each type) and tests each of the methods that you wrote. Initially, for testing purposes you can hardcode the values for Employee objects being created, but when completed you need to ask for interactive input from the user.
I am having trouble with how to write an abstract method to compute the yearly bonus inside of the employee superclass.
I am also having a lot of trouble with the EmployeePayroll class. I can't think of the best way to do the addEmployee method. I am just getting stuck and very frustrated. Help would be greatly appreciated. Thanks.This is all I have so far.
public class Employee
protected String name;
public void setName(String name)
this.name = name;
public String getName()
return name;
public class Secretary extends Employee
private int initialYear = 0000;
private double salary = 0.0;
public void setInitialYear(int initialYear)
this.initialYear = initialYear;
public int getInitialYear()
return initialYear;
public void setSalary(double salary)
this.salary = salary;
public double getSalary()
return salary;
public double computeBonus()
double bonus = 0.0;
if(2007 - initialYear < 5)
bonus = 50.00;
else if(2007 - initialYear >= 5 && initialYear <= 10)
bonus = 75.00;
else if(2007 - initialYear > 10)
bonus = 100.00;
return bonus;
public String toString()
return "Initial Year: " + initialYear + ". Salary: " + salary + ". Bonus: " + computeBonus() + ".";
public class JuniorSalesman extends Employee
private double baseSalary = 0.0;
private double commissionRate = 0.0;
private double totalSales = 0.0;
public void setBaseSalary(double baseSalary)
this.baseSalary = baseSalary;
public double getBaseSalary()
return baseSalary;
public void setCommisionRate(double commissionRate)
this.commissionRate = commissionRate;
public double commissionRate()
return commissionRate;
public void setTotalSales(double totalSales)
this.totalSales = totalSales;
public double getTotalSales()
return totalSales;
public double computeBonus()
return .001 * (baseSalary + commissionRate);
public String toString()
return "Base Salary: " + baseSalary + ". Total Sales: " + totalSales + ". Commission Rate: " + commissionRate + ". Bonus: " + computeBonus() + ".";
public class SeniorSalesman extends Employee
double totalSales = 0.0;
public void setTotalSales(double totalSales)
this.totalSales = totalSales;
public double getTotalSales()
return totalSales;
public double computeCommission()
double commissionRate = 0;
if(totalSales < 10000000)
commissionRate = 0.001;
else if(totalSales >= 10000000 && totalSales <= 25000000)
commissionRate = 0.002;
else if(totalSales > 25000000)
commissionRate = 0.0025;
return commissionRate;
public double computeBonus()
return totalSales * .0025;
public String toString()
return "Total Sales: " + totalSales + ". Commission Rate: " + computeCommission() + ". Bonus: " + computeBonus() + ".";
} -
We have a upcomming labview development project that is comming up.
I'm
looking for a labview programmer/developer with knowledge of DAQ cards
for acquireing data and signal processing (FIR/FFT's/bandpass
filtering), and some simple analog outputs and DIO for this project.
It is open to people in the US and abroad (India,Asia, etc)
We
anticipate this project will take about a days worth of programming to
get working, but we also anticipate adding more development once that
is done.
If you are interested in this project, please send me an email at jobs at intereasemedical.com
Thank you.
~AnthonyDear sir,
I am an Instrumentation and control Engineer working as a LabVIEW Application Engineer since 9 months. I am looking for good job in LabVIEW field only. And willing to work in India or abroad.I have experience of 9 month in LabVIEW field. I have experience of LabVIEW 8.5, NI Vision software, NI toolkits, PLC programming, PC and PLC interface, OPC server,Data acquisition etc.
My short introduction is given below.
Name: Bhavin K Panchal
Education: B.E - instrumentation and control
College: Dharmsinh Desai institute of technology, Nadiad.
Year of passout: 2008-2009
Adress: Brahman street, Valoti
Bilimora
Ta-Gandevi D-Navsari
Gujarat, India
Contact No.: (0) 9925848727
Attachments:
BHAVIN PANCHAL RESUME.pdf 88 KB -
Hello guys need help with reverse array
Need help reversing an array, i think my code is correct but it still does not work, so im thinking it might be something else i do not see.
so far the input for the array is
6, 25 , 10 , 5
and output is still the same
6 , 25 , 10 , 5
not sure what is going on.
public class Purse
// max possible # of coins in a purse
private static final int MAX = 10;
private int contents[];
private int count; // count # of coins stored in contents[]
* Constructor for objects of class Purse
public Purse()
contents = new int[MAX];
count = 0;
* Adds a coin to the end of a purse
* @param coinType type of coin to add
public void addCoin(int coinType)
contents[count] = coinType;
count = count + 1;
* Generates a String that holds the contents of a purse
* @return the contents of the purse, nicely formatted
public String toString()
if (count == 0)
return "()";
StringBuffer s = new StringBuffer("(");
int i = 0;
for (i = 0; i < count - 1; ++i)
s.append(contents[i] + ", "); // values neatly separated by commas
s.append(contents[i] + ")");
return s.toString();
* Calculates the value of a purse
* @return value of the purse in cents
public int value()
int sum = 0; // starts sum at zero
for( int e : contents) // sets all to e
sum = sum + e; //finds sum of array
return sum; //retur
* Reverses the order of coins in a purse and returns it
public void reverse()
int countA = 0;
int x = 0;
int y = countA - 1; // 5 - 1 = 4
for (int i = contents.length - 1; i >=0 ; i--) // 4, 3 , 2, 1, 0
countA++; // count = 5
while ( x < y)
int temp = contents[x];
contents[x] = contents [y];
contents [y] = temp;
y = y- 1; // 4 , 3 , 2, 1 , 0
x = x + 1 ; // 0 , 1, 2 , 3 , 4
}ok so i went ahead and followed what you said
public void reverse()
int a = 0;
int b = contents.length - 1;
while (b > a)
int temp = contents[a];
contents[a] = contents;
contents [b] = temp;
a++;
b--;
}and its outputting { 0, 0, 0, 0}
im thinking this is because the main array is has 10 elements with only 4 in use so this is a partial array.
Example
the array is { 6, 25, 10, 5, 0, 0, 0, 0, 0, 0,}
after the swap
{0, 0 , 0 , 0, 0 , 0 , 5 , 10 , 25, 6}
i need it to be just
{ 5, 10, 25, 6}
so it is swapping the begining and end but only with zeroes the thing is i need to reverse the array without the zeroes -
Help with Java programming project
Hi,
I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream consisting of the +, - , and 0 characters (with appropriate substitutions) one-character-at-a-time into a text file (called output.txt).
The program must use a class called AMIConverter with an object called AMI . Class AMIConverter must have a method called convert which converts an individual input character 0 or 1 into the appropriate character 0 or + or - of AMI.
It first copy the line to file output.txt. Then read the line one character at a time and pass only valid characters (0 or 1) to AMI.convert, which assumes only valid characters. The first 1 in each new 'Example' should be converted to a +.
This is what is read in, but this is just a test case.
0101<1000
1100a1000b00
1201g101
should now produce two lines of output for each 'Example', as shown below:
This should be the output of the output.txt file
Example 1
in :0101<1000
out:0+0-+000
Example 2
in :1100a1000b00
out:+-00+00000
Example 3
in :1201g101
out:+0-+0-
To elaborate more, only 1 and 0 are passed to "convert" method. All others are ignored. 0 become 0 and 1 become either + or - and the first "1" in each new example should be a +.
This is what I have so far. So far I am not able to get the "in" part, the characters (e.g. : 0101<1000 ) out to the output.txt file. I am only able to get the "out" part. And I also can't get it to display a + for the first "1" in each new examples.
import java.io.*;
public class AMIConverter
public static void main (String [] args) throws IOException
AMI ami = new AMI();
try
int ch = ' ';
int lineNum = 1;
int THE_CHAR_0 = '0';
int THE_CHAR_1 = '1';
BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
PrintWriter outfile = new PrintWriter("output.txt");
outfile.write("Example " + lineNum);//prints Example 1
outfile.println();
outfile.write("in :");
outfile.println();
outfile.write("out:");
while ((ch = infile.read()) != -1)
if (ch == '\r' || ch == '\n')
lineNum++;
outfile.println();
outfile.println();
outfile.write("Example " + lineNum);
outfile.println();
outfile.write("in :");
outfile.println();
outfile.write("out:");
else
if (ch == THE_CHAR_0)
int output = ami.convert(ch);
outfile.write(output);
else
if (ch == THE_CHAR_1)
int output = ami.convert(ch);
outfile.write(output);
}//end while
infile.close();
outfile.close();
}catch (IOException ex) {}
}//main method
}//class AMIConverter
This is my AMI class
import java.io.*;
public class AMI
int THE_CHAR_0 = '0';
int THE_CHAR_1 = '1';
int total = '+';
int minus = '-';
int count = 0;
public int convert(int ch)
try
PrintWriter outfile = new PrintWriter("output.txt");
if (ch == THE_CHAR_0)
return ch;
else
if (ch == THE_CHAR_1)
count++;
if (count%2 == 1)
ch = total;
return (ch);
else
ch = minus;
return (ch);
}catch (FileNotFoundException e) {}
return ch;
}//method convert
}//class AMI
Any help would be appreicated.
Thanks!Hi,
I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream consisting of the +, - , and 0 characters (with appropriate substitutions) one-character-at-a-time into a text file (called output.txt).
The program must use a class called AMIConverter with an object called AMI . Class AMIConverter must have a method called convert which converts an individual input character 0 or 1 into the appropriate character 0 or + or - of AMI.
It first copy the line to file output.txt. Then read the line one character at a time and pass only valid characters (0 or 1) to AMI.convert, which assumes only valid characters. The first 1 in each new 'Example' should be converted to a +.
This is what is read in, but this is just a test case.
0101<1000
1100a1000b00
1201g101
should now produce two lines of output for each 'Example', as shown below:
This should be the output of the output.txt file
Example 1
in :0101<1000
out:0+0-+000
Example 2
in :1100a1000b00
out:+-00+00000
Example 3
in :1201g101
out:+0-+0-
To elaborate more, only 1 and 0 are passed to "convert" method. All others are ignored. 0 become 0 and 1 become either + or - and the first "1" in each new example should be a +.
This is what I have so far. So far I am not able to get the "in" part, the characters (e.g. : 0101<1000 ) out to the output.txt file. I am only able to get the "out" part. And I also can't get it to display a + for the first "1" in each new examples.
import java.io.*;
public class AMIConverter
public static void main (String [] args) throws IOException
AMI ami = new AMI();
try
int ch = ' ';
int lineNum = 1;
int THE_CHAR_0 = '0';
int THE_CHAR_1 = '1';
BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
PrintWriter outfile = new PrintWriter("output.txt");
outfile.write("Example " + lineNum);//prints Example 1
outfile.println();
outfile.write("in :");
outfile.println();
outfile.write("out:");
while ((ch = infile.read()) != -1)
if (ch == '\r' || ch == '\n')
lineNum++;
outfile.println();
outfile.println();
outfile.write("Example " + lineNum);
outfile.println();
outfile.write("in :");
outfile.println();
outfile.write("out:");
else
if (ch == THE_CHAR_0)
int output = ami.convert(ch);
outfile.write(output);
else
if (ch == THE_CHAR_1)
int output = ami.convert(ch);
outfile.write(output);
}//end while
infile.close();
outfile.close();
}catch (IOException ex) {}
}//main method
}//class AMIConverterThis is my AMI class
import java.io.*;
public class AMI
int THE_CHAR_0 = '0';
int THE_CHAR_1 = '1';
int total = '+';
int minus = '-';
int count = 0;
public int convert(int ch)
try
PrintWriter outfile = new PrintWriter("output.txt");
if (ch == THE_CHAR_0)
return ch;
else
if (ch == THE_CHAR_1)
count++;
if (count%2 == 1)
ch = total;
return (ch);
else
ch = minus;
return (ch);
}catch (FileNotFoundException e) {}
return ch;
}//method convert
}//class AMIAny help would be appreicated.
Thanks! -
Display the Program/Project Monitor via a projector
I will be making a presentation to a video club on using keying and how to use Ultra Key. In order to demonstrate how the various parameters affect the cleanliness of keying I will need to output the content of the Project Monitor to a large screen via a projector. However, I need to use the laptop at the same time to actually manipulate the process. Is this doable at all ??? I use PP CS6 and Windows 7. Can the Project window displayed/exported to a projector on its own without using additional hardware..
Tommy
it all depends upon your graphics card and the software it uses.
the vga output will show on a second monitor but may not show other than a copy of the laptop monitor, or it may be that you have to send all the display out via vga or you may be lucky
if it is an oldish laptop which I presume it as as you do not state that it has a hdmi port then with vga you are limited in resolution and you may have to set up a 800x600 workspace and use that in your demo. This is something that i have had to do myself in the past when lecturing. -
In my application I have a Boolean array display, and two arrays of double precision floating point numbers.
Also, I have some graphs, which I can make the lower right corner 0,0 which visually displays my process
The array displays element 0,0 in the upper left corner, how can I make the lower right element 0,0?
Thanks
MartinIf I was only doing the Boolean display, that could possibly be a solution.
But, because of the diversity of configurations, 4 X 20 to 12 X 50, the size of the text in the X and Y values, I need to still scroll the numbers.
Here is a picture of what the page looks like.
So, when I get a red indicator for a failure, I can scroll the numbers and make a correlation, between the Boolean and X/Y values.
But, I need to do the Diagonal Flip on all three arrays to coincide with the physical process.
Attachments:
Array Layout.png 103 KB -
I'm not sure if the forum's Code of Conduct disallows such postings; I've read it and didn't find it explicitly prohibited, so I'm taking the chance. If it offends anyone, let me know and I'll request the forum administrators to delete it.
I have a cryptography software development project (3-6 months) in Silicon Valley (US) for an experienced programmer. Experience with JDBC and JCE is essential. Knowledge of PKI, smartcards and cryptographic HSMs is a plus; if not, I can teach you as long as you're willing to come upto speed really fast. For the right candidate, this could become a full-time opportunity working on some great crypto projects.
The compensation will be competitive and the work extremely interesting. All my normal contacts are busy, thus I'm reaching out to those who have an interest in this area. To contact me, send me an e-mail directly - click on my name to get my e-mail address. Only US citizens or Green Card holders, please.
Thank you for your indulgence.warnerja wrote:
Roridge wrote:
Herko_ter_Horst wrote:
Roridge wrote:
You could delimit your input entry with a comma and then split on the input String to get your integers. e.g. "1,2,3,4,5,6,7,8,9,10"Right, because comma's are so much better than spaces...Yeah, well at least I Suggested something... you are so Elitist!I could have suggested that the OP bake a cake, but that would have helped about as much as you did.
You are so Noobist!What is the deal with you two, are you like two lovers sitting next to each other determined to prove your Elite status? -
Projectfilter - filter your programming projects on VCS and filenames
I have a lot of projects checked out and sometimes need to do things like "give me all projects with java files to which i committed"
this solves exactly that
https://github.com/Dieterbe/projectfilterAWESOME. Thank you.
-
Does anyone know if it is possible to create an integrated report of all program / project risks, issues and opportunities as identified on project sites? We plan on having our project teams identify and manage these on their project sites but would like
to ability to roll this information up into a report for management review. Need to know if this is possible and how it might be done. Thanks.Hi,
are you asking for a Reporting Services Report? You can find this information in Reporting DB (2010) resp. schema dbo for reporting (2013).
Here a simple query:
SELECT PROJ.ProjectName
, ISSUE.Title AS Issue
, RISK.Title AS Risk
FROM dbo.MSP_EpmProject_UserView AS PROJ
LEFT OUTER JOIN dbo.MSP_WssIssue_OlapView AS ISSUE ON PROJ.ProjectUID = Issue.ProjectUID
LEFT OUTER JOIN dbo.MSP_WssRisk_OlapView AS RISK ON RISK.ProjectUID = PROJ.ProjectUID
Or are you looking for something different?
Regards
Barbara
To increase the value of this forum, please mark the replies that helped to solve your issue as answer. If you find answers to questions from other forum participants to be helpful, please mark them as helpful. Your participation will help others to find
an appropriate solution faster. Thanks for your support!
Maybe you are looking for
-
Apple TV does not display in Devises list
I have gone though everything on the trouble shooting list. The ATV is working just fine, connects to my network, plays updated videos and movie trailers, but I can't get any of my computers to recognize that I have an ATV. I have shut down all but o
-
8800GT for First Generation Mac Pros
Hi, thought I would post my experiences with the 8800GT card for Mac Pro. (1st Gen) Well, I use Maya, Final Cut, Photoshop and Corel Paint at work and home. I upgraded the graphics card and to be honest found no different to the old card. I normally
-
How to transfer my Nokia 6600 backup to E70 ?
Hello, About a month ago I sold my Nokia 6600 and got Nokia E70. Before I sold the Nokia 6600 I did a backup using the PC Suite. Now how can I transfer my stuff from the backup to my E70? Thanks.
-
A big hi there and hello! Ive just got my brand new Itouch and cables, and am trying to hook it up to the TV, to watch movies, yet all I get is sound?? The cables are Apple Component MB128ZA/B. My TV is a Sony Bravia KDL-37S5500. The cables are match
-
Hi Everyone, I have to query a table that stores daily information and I only need to get the current month's data out of there. There is A LOT of data in there (4 years X 15 stores X 65 depts). I was wondering if there was a way to get the current m