Streaming data to disk, need help reading data into Power Spectrum/O​ctave vi
I'm streaming data to disk in one loop, however once this finishes I'd like to read the data into power spectrum vi/Octave analysis vi in another loop. The data from the read vi is a string and power spectrum vi needs 1d waveform. Does anyone have experience with this process?
From your general description, I gather you are streaming to a text based file (comma or tab separated spreadsheet format) and would like to analyse this data with a power spectrum or octave analysis when you finish. Since you are streaming, I assume you have a lot of data. Do you have more than one channel?
In any case, you have two simple options (and lots of complex ones). You can either read the data back from disk and convert it to a 1D array (try the Read From Spreadsheet File.vi - will get a 2D array, take the first column or the column of your choice if you have more than one channel) or you can use the Spreadsheet String to Array primitive to create an array from your text data before you save it to disk.
If your data rate is slow enough, you can analyze as you acquire and store.
Taking your data as text is very inefficient. What you really want to do is read the data as binary, use that for your analysis, and use something like the Write to Spreadsheet File.vi to save text data to disk.
This account is no longer active. Contact ShadesOfGray for current posts and information.
Similar Messages
-
Need Help:Reading Data from RU payroll cluster for table GRREC
Hi...
I need help on how to read data from RU cluster table for table GRREC for the employee & run date and get the value from structure PC292 .
Please let me know about the includes and the import and export statements to be used.
Thanks in advance,
RAVI.Hi,
Here goes pseudocode
Includes:
include: rpppxd00 ,
rpppxd10 ,
rpc2cd09 ,
rpc2rx02_ce , "if ldb pnp_ce is used else use the same include with out _ce
rpc2rx29 ,
rpc2rx39 ,
rpppxm00 ,
rpc2ruu0_ce ,
Declare:
DATA : i_rgdir LIKE pc261 OCCURS 0 WITH HEADER LINE ,
i_result TYPE pay99_result OCCURS 0 WITH HEADER LINE ,
i_grrec LIKE pc292 OCCURS 0 WITH HEADER LINE .
start-of-selection:
GET pernr.
Get the RGDIR VALUE for the current PERNR & selected Molga
get rgdir data TABLES i_rgdir
USING pernr-pernr
p_molga " parameter
CD-KEY-PERNR = PERNR-PERNR.
RP-IMP-C2-CU.
i_rgdir [] = rgdir[].
LOOP AT i_rgdir WHERE fpbeg LE pn-endda
AND fpend GE pn-begda
AND srtza EQ 'A'
AND void NE 'V'.
get_result_tabs TABLES i_result
USING 'RU' " US cluster
pernr-pernr
i_rgdir-seqnr
RX-KEY-PERNR = PERNR-PERNR.
UNPACK i_RGDIR-SEQNR TO RX-KEY-SEQNO.
RP-IMP-C2-RU.
i_grrec[] = i_result-inter-grrec[].
LOOP AT i_grrec.
case i_grrec.
use wage types required here and pass the data to output table.
endcase.
endloop.
endloop
end-of-selction. -
Need help on data coversion to be read by Java program
Hello everyone,
I have a challenging project to generate reports from MVS (mainframe) data and using Java as the programming language to read this data and generate reports. The Java program will execute on Wintel platform and AIX/UNIX platform.
The data that I need to read (DCOLLECT idcams utility) is in binary/EBCDIC variable record format and resides in mainframe and transmitted via FTP to wintel platform.
I tried converting the data to ASCII format before tranferering but the transfered data seems to be wrapped around and not sure how to handle it. I could transfer the whole thing in binary format and then read and convert at the same time( I believe Java can read EBCDIC accoding to my notes).
I am sure some one have done this once before and I do not want to reinvent the wheel againg. I need your help in what direction to take for best aproach reading this data.
Your suggestions would be appreciated
Thanks
Ulises (arsi)Thanks for you replies guys!
I need to use java because the ultimate reporting tool
is going to be a service developed in Jini.
The reason I believe the data seem to be wrapped
around after ftp transfer is because when I edited
(TSO FSE from MVS) all text data is aligned withing
the same column.
After data is transmitted via FTP (converted to ASCII
during trasmition) and edited with wordpad, text
characters do not seem to be on the same possition.
They are scattered all over the display area. Is
possible this could be a display affect from winword
but not sure.
The MVS job to FTP the file follows:
//STEP01 EXEC PGM=FTP,
// PARM='FTP.MIAMIDADE.GOV (EXIT'
//SYSPRINT DD SYSOUT=*
//OUTPUT DD SYSOUT=*
//SYSIN DD *
user-name/password
CD /storage
CD UAL
ASCII
PUT 'STORAGE.DCOLLECT.TYPV' 'DCOLLECT_TYPEV.TXT'
ls -l
close
quit
Words of advice appreciated
Ulises (arsi)
YES! 1st mistake ... don't use WordPad for this ... your NotePad, Dos, or some other pure text editor. -
Need to read data from pipe separated file using POJO?
Hi,
I need to read data from pipe separated file using POJO.
There is config.properties file which consists of the
data mapping.
Can you help me with sample code or help?
Regards
Regards
Taton
Edited by: Taton on Mar 7, 2009 4:41 PMIt's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
[http://java.sun.com/docs/books/tutorial/essential/io/]
*Unless you write a bunch of JNI code to replicate what the java.io classes are doing. -
I am printing a calendar and certain events will be helds on certain dates.
One can edit the event if it has not passed the date. Events in the past can be viewed but not edited.
When I query the database the date must be formatted dd-MMM-yy
I am able to get today's date by doing this:
java.util.Date today = new java.util.Date();
String formatString = "dd-MMM-yy";
SimpleDateFormat sdf = new SimpleDateFormat(formatString);
String today_str = sdf.format(today);
My code for printing the calendar: I left out some of the table formatting in the JSP page.
GregorianCalendar d = new GregorianCalendar();
int today = d.get(Calendar.DAY_OF_MONTH);
int month = d.get(Calendar.MONTH);
d.set(Calendar.DAY_OF_MONTH,1);
int weekday = d.get(Calendar.DAY_OF_WEEK);
for(int i = Calendar.SUNDAY; i < weekday; i++)
out.print("<td> </td>");
do {
int day = d.get(Calendar.DAY_OF_MONTH);
out.print("<td>" + day + "</td>");
String formatString = "dd-MMM-yy";
SimpleDateFormat sdf = new SimpleDateFormat(formatString);
//if(event exists on this day
// Get results
// print link for viewing
// if (after today) print link for edit
if(weekday == Calendar.SATURDAY)
out.println("</tr><tr valign=top>");
d.add(Calendar.DAY_OF_MONTH,1);
weekday = d.get(Calendar.DAY_OF_WEEK);
} while(d.get(Calendar.MONTH) == month);
if(weekday != Calendar.SUNDAY)
System.out.println();
The part I need help on is this:
//if(event exists on this day
// Get results
// print link for viewing
// if (after today) print link for edit
I'm looping through each day of the month to print the days. I have the month, day, year as integers. How can I create a date object out of that and compare it to today's date to test if it's before or after today???
All the function in the Date class that I think would do this have been deprecated.Need Help with Dates
Here is some information about dates:
There are many edible palm fruits, and one of the most widespread and favored of these is the data (Phoenix dactylifera). Dates were cultivated in ancient land from Mesopotamia to prehistoric Egypt, possibly as early as 6000 B.C. Then--as now--dates were a staple for the natives of those dry regions. Much later, Arabs spread dates around northern Africa, and dates were introduced into California by the Spaniards in 1765, around Mission San Ignacio.
The date prefers dry, hot climates, because date fruits are injured at temperatures of 20 degrees F, and the damp climate of the California coast was not favorable for fruit production. In the mid-1800s, the date industry developed in California's hot interior valleys and in Arizona. Now the date industry in the United States is localized mostly in the Coachella Valley, where the sandy soils permit the plants to be deeply irrigated. Today the new varieties, mostly introduced in this century, produce about 40 million pounds of dates per annum, or over 60% of the dates consumed in this country. The rest are imported mainly from Persia. According to one survey, about one million people are engaged entirely in date palm cultivation worldwide.
Hope that helps. -
Need help in date Validation Urgent
Hi ,
We need help in Date Validation.
we have 2 Date fields on the form Start Date, End Date
The requirement is: End Date (May not be greater than 30 years from the start date).
I have written following script on End Date Exit event. But the problem is its calculating 30 years from the Current Date not from the Start Date
var tDate = util.scand("mm/dd/yyyy", new Date());
var M = tDate.getMonth();
var D = tDate.getDate();
var Y = tDate.getFullYear();
var SRes = util.printd("yyyy-mm-dd", new Date((Y+30), M,D) );
//app.alert(SRes)if (SRes <= this.rawValue){
app.alert("May not be greater than 30 years from the start date")
xfa.host.setFocus(
this);}
can someone please help me
Regards,
JayHi,
You'll need to get javascript date from LCD field, and calculate & compare with the future date in javascript date.
try following script;
var sDate = StartDate.rawValue;
var wkStartDate = util.scand("yyyy-mm-dd", sDate);
var nYear = wkStartDate.getFullYear();
var nMonth = wkStartDate.getMonth();
var nDay = wkStartDate.getDate();
var wkFutureDate = new Date(nYear + 30 , nMonth, nDay);
sDate = EndDate.rawValue;
var wkEndDate = util.scand("yyyy-mm-dd", sDate);
if (wkEndDate.getTime() > wkFutureDate.getTime()){
xfa.host.messageBox("May not be greater than 30 years from the start date");
xfa.host.setFocus(this); -
Need to read data from a text file
I need to read data from a text file and create my own hash table out of it. I'm not allowed to use the built in Java class, so how would I go implementing my own reading method and hash table class?
It's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
[http://java.sun.com/docs/books/tutorial/essential/io/]
*Unless you write a bunch of JNI code to replicate what the java.io classes are doing. -
I need to read data from MQ? any example of OFSML ?
I need to read data from MQ so what I should know about this MQ properties ?? such ip,name,....
I'm new in MQ programming
and it can be over internet or local network only ?
I will used the OFSML
any one know any thing about OFSML or any example ?? Open Financial Services XML interface
(http://dts.temenos.com/ofsml/)It's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
[http://java.sun.com/docs/books/tutorial/essential/io/]
*Unless you write a bunch of JNI code to replicate what the java.io classes are doing. -
Need help reading burn CDR mp3 and dvdrw from my superdrive
my Super Drive was fine untill i upgrade to Maverick now it wouldnt read the music on all of my burn cdr disk and dvdrw . ALso .need help reading my external 2TB External Ntfs Hard drive.....
To many conflicting information...
my Super Drive was fine untill i upgrade to Maverick
Per your system profile: "Mac mini, Mac OS 9.1.x"
Mac Minis do not have a superdrive. You also posted in the Intel iMac forums.
Please correct and/or update so that you will be provided w/the correct troubleshooting suggestions. -
I need help identifying which Magsafe Power Adapter I need for my Macbook Pro Model A1398, EMC 2673?
Provided the computer-end fits, you are free to use one with a HIGHER Wattage rating. No damage whatsoever will be done to any component, but it will likely run cooler (but may be slightly heavier).
If you use one with too LOW a Wattage rating, you will not be able to charge and run at the same time, and your computer's top speed (for its most intensive computations) will be limited. -
Help needed in reading data from a Crystal Report
I am trying to read data values from a saved crystal report. (groovy code snippet below)
I open a new ReportClientDocument and set the RAS using the inprocConnectionString property.
Then I get the rowsetController and set defaultNumOfBrowsingRecords, rowsetBatchSize and maxNumOfRecords all to 1000000
Using the browseFieldValues method after that returns only 100 records. I want to get all.
ReportClientDocument clientDocSaved;
def pathout=rc.pathToSavedReports+rr.path;
//****** BEGIN OPEN SAVED SNAPSHOT ************
clientDocSaved = new ReportClientDocument();
clientDocSaved.setReportAppServer(ReportClientDocument.inprocConnectionString);
// Open report
println("Reading file in.")
clientDocSaved.open(pathout, OpenReportOptions._openAsReadOnly);
def rowsetController = clientDocSaved.getRowsetController()
rowsetController.setDefaultNumOfBrowsingRecords(1000000)
rowsetController.setRowsetBatchSize(1000000)
rowsetController.setMaxNumOfRecords(1000000)
//setup metadata
IRowsetMetaData rowsetMetaData = new RowsetMetaData()
Fields fields = clientDocSaved.getDataDefController().getDataDefinition().getResultFields()
rowsetMetaData.setDataFields(fields)
def values = rowsetController.browseFieldValues(fields.get(0), 1000000)
values.each{value->
println(value.displayText(new Locale("ENGLISH")))
Before using the browseFieldValues method I was trying to use a rowsetCursor
//get the rowset cursor to navigate through the results
RowsetCursor rowsetCursor = clientDoc.getRowsetController().createCursor(null, rowsetMetaData)
//navigate through the rowset and log the name and value
rowsetCursor.moveTo(0)
while(!rowsetCursor.isEOF()){
Record currentRecord = rowsetCursor.getCurrentRecord()
//println("current record number: " + rowsetCursor.getCurrentRecordNumber())
for(int i=0;i<fields.size();i++){
//println("Column - "+fields.get(i).getName())
if (currentRecord.size()>0){
println(currentRecord.getValue(i))
rowsetCursor.moveNext()
the currentRecord was always an empty list and I did not get any data values at all.
Am I missing something in using these approaches?
I'm fairly new to using the Java SDK for CR. Any help will be greatly appreciated.
Thankshi, I am trying this second method to read the values from report. but all the records comming as null. Kindly help me to resolve this issue.
-
hey ppl
i have a datagrid in my form.i need to read input(fields..sort of a database) from a text file and display its contents in the datagrid.
how can this be done.. and also after every few seconds reading event should be re executed.. and that the contents of the datagrid will keep changing as per the changes in the file...
please help as this is urgent and important.. if possible please provide me with an example code as i am completely new to flex...
thanks.....It's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
[http://java.sun.com/docs/books/tutorial/essential/io/]
*Unless you write a bunch of JNI code to replicate what the java.io classes are doing. -
I need help restoring data from my time machine.
1) On the time machine, where do I find the TRASH file that is located on the dock in my desktop? I'd like to restore that to a prior date but can't find it.
2) I DID A VERY BAD THING & need help to get back to where I was before. I wanted to delete files that were taking up lots of space. My OTHER section was using 160G. I downloaded OmniDiskSweep and found that 120G was being used by my virtual machine (I run Quicken in Windows, through VMware). I started to delete files that were called Snapshots assuming these were the snapshots that the program regularly takes of my files. Apparently they were not. I also deleted the program Windows XP Professional because that was never used. When I try to open VM or quicken program, it says it is missing a particular snapshot, i.e. Snapshot 11104. I deleted about 20 of these. I left all the other files that said Windows XP Home Edition. But now it shows that I only have the Professional Edition, even though that's what I deleted. I'm trying to restore from Time Machine and it looks like the information is not there - I've tried various different backups and nothing seems to have the information I need. The earliest back up I have is from 5/7 when I started time machine on a new external 1TB HD. Would that have the information I need since it's the very first back up? Please Help.I am assuming it's real data because it's taking up storage on my HD. It falls in the category "other" and the total of this section is 160G. Here is a snapshot of the virtual machine.
I also took a shot of the VM snapshots & it tells how much space is being taken up by the snapshots.
I've now changed the number of snapshots taken down to 12 (didn't know I had this option) & I can delete alot of the 21 snapshots that have already been saved. I have no idea how much of the HD was set aside for the VM because someone else installed it for me 5 years ago. I've had enough problems with it over the years that I've wanted to switch to Quicken for Mac or find another financial program to use. I've upgraded the VM 2x over the years, but didn't want to spend $100 for Version 5. I understand the concept of a VM but that's about all.
I did do the disk cleanup in Windows on the C drive. I deleted 700 MB of temporary files and then compressed 4G of data down to 2G. While the cleanup was progressing it said that the C drive was 30.99G and 78% of it was free. That just doesn't make sense to me. It recommended a defrag, so I did that also.
I'm pretty sure it's real data because I recently had to switch from a 320G external HD for TM, to a 1T HD. One TM backup was over 300G which I found to be excessive because I basically use my computer for mail, some word processing, and my financial data.
Thanks again for all your help. I really appreciate it. -
Need help pulling data from an outside file into my array. Please help =)
Hi,
I need help adapting my array to read the interest rates from an outside file. Here is my code and the outside file I wrote. Please help. Oh, the array in question is on line 259, inside of my calculation() method.
Thanks...
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.io.*;
import javax.swing.JOptionPane;
public class Workshop5 extends JFrame implements ActionListener
//declare gui components
//declare labels
JPanel contentPane = new JPanel();
JPanel graphPane = new JPanel();
JLabel instructionLabel = new JLabel();
JLabel amountLabel = new JLabel();
JLabel orLabel = new JLabel();
JLabel comboBoxLabel = new JLabel();
JLabel termLabel = new JLabel();
JLabel rateLabel = new JLabel();
JLabel calcLabel = new JLabel();
JLabel paymentLabel = new JLabel();
JLabel tableLabel = new JLabel();
//declare font object
Font labelFont = new Font("Tahoma", Font.PLAIN, 16);
//declare text fields
JTextField amountField = new JTextField(20);
JTextField termField = new JTextField(20);
JTextField rateField = new JTextField(20);
JTextField paymentField= new JTextField(20);
//declare combo box for loan selection
JComboBox comboBox = new JComboBox();
//declare button group and radio buttons
ButtonGroup buttonGroup = new ButtonGroup();
JRadioButton enterRadioButton = new JRadioButton("Enter amount, term, & rate", true);
JRadioButton selectRadioButton = new JRadioButton("Select a preset term/rate loan", false);
//declare button objects
JButton clearButton = new JButton();
JButton calcButton = new JButton();
JButton quitButton = new JButton();
//declare text area for amortization
JTextArea amortTextArea = new JTextArea();
JTextArea testTextArea = new JTextArea();
//declare scroll bar for amortization table
JScrollPane scrollPane = new JScrollPane(amortTextArea,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
public Workshop5()
instructionLabel.setText("Choose one of the following payment calculation options:");
instructionLabel.setFont(new Font("Tahoma",Font.PLAIN,16));
//adds both buttons to button group
buttonGroup.add(enterRadioButton);
buttonGroup.add(selectRadioButton);
enterRadioButton.setFont(labelFont);
enterRadioButton.setBackground(Color.WHITE);
enterRadioButton.setContentAreaFilled(false);
enterRadioButton.addActionListener(this); //adds action listener to enter radio button
orLabel.setText("OR");
orLabel.setFont(new Font("Tahoma",Font.BOLD,18));
selectRadioButton.setFont(labelFont);
selectRadioButton.setBackground(Color.WHITE);
selectRadioButton.setContentAreaFilled(false);
selectRadioButton.addActionListener(this); //adds action listener to select radio button
amountLabel.setText("Enter mortgage amount");
amountLabel.setFont(new Font("Tahoma", Font.PLAIN,16));
amountField.requestFocusInWindow();
termLabel.setText("Enter term length in years:");
termLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
rateLabel.setText("Enter interest rate:");
rateLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
comboBoxLabel.setText("Select a loan:");
comboBoxLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
comboBox.setBackground(new Color(255,255,255));
comboBox.setFont(new Font("Tahoma", Font.PLAIN, 14));
comboBox.setEnabled(false);
ComboBox();
calcLabel.setText("Press Calculate button to determine monthly payment.");
calcLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
calcButton.setText("Calculate");
calcButton.setFont(new Font("Tahoma", Font.BOLD, 14));
calcButton.addActionListener(this);
//define monthly payment label
paymentLabel.setText("Monthly payment:");
paymentLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
//define monthly payment text field
paymentField.setFont(new Font("Tahoma", Font.BOLD,16));
paymentField.setBackground(new Color(255,255,255));
paymentField.setEditable(false);
//define clear button
clearButton.setText("Clear");
clearButton.setFont(new Font("Tahoma", Font.BOLD,14));
clearButton.addActionListener(this);
//define quit button
quitButton.setText("Quit");
quitButton.setFont(new Font("Tahoma", Font.BOLD,14));
quitButton.addActionListener(this);
tableLabel.setText("Amoritization Table");
tableLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
graphPane.setBackground(Color.WHITE);
//add components to content
getContentPane().add(contentPane);
contentPane.setLayout(null);
addComponent(contentPane, instructionLabel, 80,10,450,26);
addComponent(contentPane, enterRadioButton, 30,40,220,30);
addComponent(contentPane, orLabel, 280,40,100,30);
addComponent(contentPane, selectRadioButton, 335,40,350,30);
addComponent(contentPane, amountLabel, 100,80,220,26);
addComponent(contentPane, amountField, 300,80,150,26);
addComponent(contentPane, termLabel, 15,125,200,30);
addComponent(contentPane, termField, 195,125,125,30);
addComponent(contentPane, rateLabel, 62,160,200,30);
addComponent(contentPane, rateField, 195,165,125,30);
addComponent(contentPane, comboBoxLabel, 400,125,200,26);
addComponent(contentPane, comboBox, 400,155,150,30);
addComponent(contentPane, calcLabel, 100,200,400,30);
addComponent(contentPane, calcButton, 250,240,100,30);
addComponent(contentPane, paymentLabel, 150,285,200,30);
addComponent(contentPane, paymentField, 300,285,100,30);
addComponent(contentPane, clearButton, 100,330,100,30);
addComponent(contentPane, quitButton, 400,330,100,30);
addComponent(contentPane, tableLabel, 200,370,300,26);
addComponent(contentPane, scrollPane, 10,400,450,360);
addComponent(contentPane, graphPane, 475,400,305,360);
//add window listener to close window when user presses X
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
pack();
//method to add components
private void addComponent(Container container, Component c, int x, int y, int width, int height)
c.setBounds(x, y, width, height);
container.add(c);
//action performed method
public void actionPerformed(ActionEvent event)
Object source = event.getSource();
if (source == calcButton)
Calculate();
if (source == clearButton)
Clear();
if (source == quitButton)
Exit();
//defines active area based on user selection of mortgage calculation method
//if user chooses to enter the mortgage manually, combo box fields are inactive
if (source == enterRadioButton)
comboBox.setEnabled(false);
termField.setEnabled(true);
termField.setEditable(true);
rateField.setEnabled(true);
rateField.setEditable(true);
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
//if user chooses to select from a preset mortgage, rate and term fields are inactive
if (source == selectRadioButton)
comboBox.setEnabled(true);
termField.setEnabled(false);
termField.setEditable(false);
rateField.setEnabled(false);
rateField.setEditable(false);
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
}//end of action performed method
//combo box method
public void ComboBox()
String[] LoanArray = {" 7 years at 5.35 %", " 15 years at 5.50 %", " 30 years at 5.75 %"};
for (int i = 0; i < LoanArray.length; i++)
comboBox.addItem(LoanArray);
}//end combo box method
//calculation method
void Calculate()
//resets fields
paymentField.setText("");
amortTextArea.setText("");
//calculation variables
NumberFormat currency = NumberFormat.getCurrencyInstance();
int [] termArray = {7, 15, 30}; //array of years
double [] yearlyInterestArray = {5.35, 5.5, 5.75}; //array of interest
int totalMonths = 0; //total months
double Loan = 0.0; //amount of loan
double MonthlyInterest = 0.0; //monthly interest rate
double Payment = 0.0; //calculate payment
double monthlyPayment = 0.0; //calculate monthly payment
double Interest = 0.0; //variable for Interest Array input
int Term = 0; //variable for Term Array input
double NewMonthlyInterest = 0.0; //new interest amount
double NewLoan = 0.0; //new loan amount
double Reduction = 0.0; //principle reduction
//validate input
try
Loan = Double.parseDouble(amountField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid Entry. Please enter valid loan amount.", "Error", JOptionPane.WARNING_MESSAGE);
//resets input fields after error message
amountField.setText("");
amountField.requestFocusInWindow();
//if select button is chosen
if (selectRadioButton.isSelected())
int index = comboBox.getSelectedIndex();
Term = termArray[index];
Interest = yearlyInterestArray[index];
//if user chooses to enter mortgage information
else
if (enterRadioButton.isSelected())
//validates input
try
Term = Integer.parseInt(termField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid term length in years.", "Error",JOptionPane.WARNING_MESSAGE);
//clears fields after error message
termField.setText("");
termField.requestFocusInWindow();
try
Interest = Double.parseDouble(rateField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid rate (without percent symbol).","Error",JOptionPane.WARNING_MESSAGE);
//clears fields after error message
rateField.setText("");
rateField.requestFocusInWindow();
//perform calculations
if (Loan > 0)
Loan = Double.parseDouble(amountField.getText());
MonthlyInterest = (Interest / 12)/100;
totalMonths = Term * 12;
monthlyPayment = Loan * MonthlyInterest *(Math.pow((1 + MonthlyInterest), totalMonths)/(Math.pow((1 + MonthlyInterest), totalMonths)-1));
paymentField.setText("" + currency.format(monthlyPayment));
//send information to amortization text area
amortTextArea.append("Number\t");
amortTextArea.append(" Amount\t");
amortTextArea.append("Interest\t");
amortTextArea.append("Principle\t");
amortTextArea.append("Balance\n");
NewLoan = Loan;
for (int i = 1; i <= totalMonths; i++)
NewMonthlyInterest = MonthlyInterest * NewLoan;
Reduction = monthlyPayment - NewMonthlyInterest;
NewLoan = NewLoan - Reduction;
amortTextArea.append(" " + i +"\t");
amortTextArea.append(" " + currency.format(monthlyPayment) + "\t");
amortTextArea.append(" " + currency.format(NewMonthlyInterest)+ "\t");
amortTextArea.append(" " + currency.format(Reduction) + "\t");
amortTextArea.append(" " + currency.format(NewLoan) + "\n");
//resets fields if loan amount is less than zero
if((Loan <= 0 || Term <= 0 || Interest <= 0))
paymentField.setText("");
amortTextArea.setText("");
}//end calcualtion method
//clear method
void Clear()
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
}//end of clear method
//main method
public static void main(String args[])
Workshop5 f = new Workshop5();
f.setTitle("Carol's Mortgage Calculator");
f.setBounds(200,100,800,800);
f.setResizable(false);
f.setVisible(true);
}//end of main method
//exit method
void Exit()
System.exit(0);
}//end of exit method
}//program end
My data file is called: "InterestData.dat" and only contains the following text:
5.35, 5.5, 5.75Ok, now I am getting this error message:
cannot resolve symbol method lenght()
Please help me out here, this is due tomorrow and I've been killing myself on it...
attaching program with revised code included, see beginning of calculation method line 250:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.* ;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.io.*;
import javax.swing.JOptionPane;
public class Workshop5 extends JFrame implements ActionListener
//declare gui components
//declare labels
JPanel contentPane = new JPanel();
JPanel graphPane = new JPanel();
JLabel instructionLabel = new JLabel();
JLabel amountLabel = new JLabel();
JLabel orLabel = new JLabel();
JLabel comboBoxLabel = new JLabel();
JLabel termLabel = new JLabel();
JLabel rateLabel = new JLabel();
JLabel calcLabel = new JLabel();
JLabel paymentLabel = new JLabel();
JLabel tableLabel = new JLabel();
//declare font object
Font labelFont = new Font("Tahoma", Font.PLAIN, 16);
//declare text fields
JTextField amountField = new JTextField(20);
JTextField termField = new JTextField(20);
JTextField rateField = new JTextField(20);
JTextField paymentField= new JTextField(20);
//declare combo box for loan selection
JComboBox comboBox = new JComboBox();
//declare button group and radio buttons
ButtonGroup buttonGroup = new ButtonGroup();
JRadioButton enterRadioButton = new JRadioButton("Enter amount, term, & rate", true);
JRadioButton selectRadioButton = new JRadioButton("Select a preset term/rate loan", false);
//declare button objects
JButton clearButton = new JButton();
JButton calcButton = new JButton();
JButton quitButton = new JButton();
//declare text area for amortization
JTextArea amortTextArea = new JTextArea();
JTextArea testTextArea = new JTextArea();
//declare scroll bar for amortization table
JScrollPane scrollPane = new JScrollPane(amortTextArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
public Workshop5()
instructionLabel.setText("Choose one of the following payment calculation options:");
instructionLabel.setFont(new Font("Tahoma",Font.PLAIN,16));
//adds both buttons to button group
buttonGroup.add(enterRadioButton);
buttonGroup.add (selectRadioButton);
enterRadioButton.setFont(labelFont);
enterRadioButton.setBackground(Color.WHITE);
enterRadioButton.setContentAreaFilled(false);
enterRadioButton.addActionListener(this); //adds action listener to enter radio button
orLabel.setText("OR");
orLabel.setFont(new Font("Tahoma",Font.BOLD,18));
selectRadioButton.setFont(labelFont);
selectRadioButton.setBackground(Color.WHITE);
selectRadioButton.setContentAreaFilled(false);
selectRadioButton.addActionListener (this); //adds action listener to select radio button
amountLabel.setText("Enter mortgage amount");
amountLabel.setFont(new Font("Tahoma", Font.PLAIN,16));
amountField.requestFocusInWindow();
termLabel.setText("Enter term length in years:");
termLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
rateLabel.setText("Enter interest rate:");
rateLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
comboBoxLabel.setText("Select a loan:");
comboBoxLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
comboBox.setBackground(new Color(255,255,255));
comboBox.setFont(new Font("Tahoma", Font.PLAIN, 14));
comboBox.setEnabled(false);
ComboBox();
calcLabel.setText("Press Calculate button to determine monthly payment.");
calcLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
calcButton.setText("Calculate");
calcButton.setFont(new Font("Tahoma", Font.BOLD, 14));
calcButton.setBackground(new Color(202,255,112));
calcButton.addActionListener(this);
//define monthly payment label
paymentLabel.setText("Monthly payment:");
paymentLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
//define monthly payment text field
paymentField.setFont (new Font("Tahoma", Font.BOLD,16));
paymentField.setBackground(new Color(255,255,255));
paymentField.setEditable(false);
//define clear button
clearButton.setText("Clear");
clearButton.setFont(new Font("Tahoma", Font.BOLD,14));
clearButton.setBackground(new Color(202,255,112));
clearButton.addActionListener(this);
//define quit button
quitButton.setText("Quit");
quitButton.setFont(new Font("Tahoma", Font.BOLD,14));
quitButton.setBackground(new Color(202,255,112));
quitButton.addActionListener(this);
//define label for amortization table
tableLabel.setText ("Amoritization Table");
tableLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
graphPane.setBackground(Color.WHITE);
//add components to content
getContentPane().add(contentPane);
contentPane.setLayout(null);
addComponent(contentPane, instructionLabel, 80,10,450,26);
addComponent(contentPane, enterRadioButton, 30,40,220,30);
addComponent(contentPane, orLabel, 280,40,100,30);
addComponent(contentPane, selectRadioButton, 335,40,350,30);
addComponent(contentPane, amountLabel, 100,80,220,26);
addComponent(contentPane, amountField, 300,80,150,26);
addComponent(contentPane, termLabel, 15,125,200,30);
addComponent(contentPane, termField, 195,125,125,30);
addComponent(contentPane, rateLabel, 62,160,200,30);
addComponent(contentPane, rateField, 195,165,125,30);
addComponent(contentPane, comboBoxLabel, 400,125,200,26);
addComponent(contentPane, comboBox, 400,155,150,30);
addComponent(contentPane, calcLabel, 100,200,400,30);
addComponent(contentPane, calcButton, 250,240,100,30);
addComponent(contentPane, paymentLabel, 150,285,200,30);
addComponent(contentPane, paymentField, 300,285,100,30);
addComponent(contentPane, clearButton, 100,330,100,30);
addComponent(contentPane, quitButton, 400,330,100,30);
addComponent(contentPane, tableLabel, 200,370,300,26);
addComponent(contentPane, scrollPane, 10,400,450,360);
addComponent(contentPane, graphPane, 475,400,305,360);
//add window listener to close window when user presses X
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
pack();
//method to add components
private void addComponent(Container container, Component c, int x, int y, int width, int height)
c.setBounds(x, y, width, height);
container.add(c);
//action performed method
public void actionPerformed(ActionEvent event)
Object source = event.getSource();
if (source == calcButton)
Calculate();
if (source == clearButton)
Clear();
if (source == quitButton)
Exit();
//defines active area based on user selection of mortgage calculation method
//if user chooses to enter the mortgage manually, combo box fields are inactive
if (source == enterRadioButton)
comboBox.setEnabled(false);
termField.setEnabled(true);
termField.setEditable(true);
rateField.setEnabled(true);
rateField.setEditable(true);
amountField.setText ("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText ("");
amortTextArea.setText("");
//if user chooses to select from a preset mortgage, rate and term fields are inactive
if (source == selectRadioButton)
comboBox.setEnabled(true);
termField.setEnabled(false);
termField.setEditable(false);
rateField.setEnabled (false);
rateField.setEditable(false);
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText ("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
}//end of action performed method
//combo box method
public void ComboBox()
String[] LoanArray = {" 7 years at 5.35 %", " 15 years at 5.50 %", " 30 years at 5.75 %"};
for (int i = 0; i < LoanArray.length; i++)
comboBox.addItem(LoanArray);
}//end combo box method
//calculation method
void Calculate()
//resets fields
paymentField.setText("");
amortTextArea.setText("");
//calculation variables
NumberFormat currency = NumberFormat.getCurrencyInstance();
//declare input stream object
InputStream istream;
//create a file object to refer to the outside file
File interestData = new File("InterestFile.dat");
//assign instream to the new file object
istream = new FileInputStream(interestData);
try
StringBuffer sb = new StringBuffer();
BufferedReader in = new BufferedReader(new FileReader(interestData));
String line = "";
while((line = in.readLine()) != null)
sb.append(line);
in.close();
String fileData = sb.toString();
String[] splitData = fileData.split(", ");
double [] yearlyInterestArray = new double[splitData.length()];
for(int j = 0; j < splitData.length(); j++)
yearlyInterestArray[j] = new Double(splitData[j]).doubleValue();
catch (IOException e)
JOptionPane.showMessageDialog(null, "File does not exist." + e.getMessage());
int [] termArray = {7, 15, 30}; //array of years
double [] yearlyInterestArray = { 5.35, 5.5, 5.75}; //array of interest
int totalMonths = 0; //total months
double Loan = 0.0; //amount of loan
double MonthlyInterest = 0.0; //monthly interest rate
double Payment = 0.0; //calculate payment
double monthlyPayment = 0.0; //calculate monthly payment
double Interest = 0.0; //variable for Interest Array input
int Term = 0; //variable for Term Array input
double NewMonthlyInterest = 0.0; //new interest amount
double NewLoan = 0.0; //new loan amount
double Reduction = 0.0; //principle reduction
//validate input
try
Loan = Double.parseDouble(amountField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid Entry. Please enter valid loan amount.", "Error", JOptionPane.WARNING_MESSAGE);
//resets input fields after error message
amountField.setText("");
amountField.requestFocusInWindow ();
//if select button is chosen
if (selectRadioButton.isSelected())
int index = comboBox.getSelectedIndex ();
Term = termArray[index];
Interest = yearlyInterestArray[index];
//if user chooses to enter mortgage information
else
if (enterRadioButton.isSelected())
//validates input
try
Term = Integer.parseInt(termField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid term length in years.", "Error",JOptionPane.WARNING_MESSAGE);
//clears fields after error message
termField.setText("");
termField.requestFocusInWindow();
try
Interest = Double.parseDouble(rateField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid rate (without percent symbol).","Error",JOptionPane.WARNING_MESSAGE);
//clears fields after error message
rateField.setText("");
rateField.requestFocusInWindow();
//perform calculations
if (Loan > 0)
Loan = Double.parseDouble(amountField.getText ());
MonthlyInterest = (Interest / 12)/100;
totalMonths = Term * 12;
monthlyPayment = Loan * MonthlyInterest *(Math.pow ((1 + MonthlyInterest), totalMonths)/(Math.pow((1 + MonthlyInterest), totalMonths)-1));
paymentField.setText("" + currency.format(monthlyPayment));
//send information to amortization text area
amortTextArea.append("Number\t");
amortTextArea.append(" Amount\t");
amortTextArea.append("Interest\t");
amortTextArea.append("Principle\t");
amortTextArea.append("Balance\n");
NewLoan = Loan;
for (int i = 1; i <= totalMonths; i++)
NewMonthlyInterest = MonthlyInterest * NewLoan;
Reduction = monthlyPayment - NewMonthlyInterest;
NewLoan = NewLoan - Reduction;
amortTextArea.append(" " + i +"\t");
amortTextArea.append (" " + currency.format(monthlyPayment) + "\t");
amortTextArea.append(" " + currency.format(NewMonthlyInterest)+ "\t");
amortTextArea.append(" " + currency.format(Reduction) + "\t");
amortTextArea.append(" " + currency.format(NewLoan) + "\n");
//resets fields if loan amount is less than zero
if((Loan <= 0 || Term <= 0 || Interest <= 0))
paymentField.setText("");
amortTextArea.setText("");
}//end calcualtion method
//clear method
void Clear()
amountField.setText("");
amountField.requestFocusInWindow();
termField.setText("");
rateField.setText("");
paymentField.setText("");
amortTextArea.setText("");
}//end of clear method
//main method
public static void main(String args[])
Workshop5 f = new Workshop5();
f.setTitle("Carol's Mortgage Calculator");
f.setBounds(200,100,800,800);
f.setResizable(false);
f.setVisible(true);
}//end of main method
//exit method
void Exit()
System.exit(0);
}//end of exit method
}//program end -
Need Help with data type conversion
Hello People,
I am new to java, i need some help with data type conversion:
I have variable(string) storing IP Address
IPAddr="10.10.103.10"
I have to call a library function which passes IP Address and does something and returns me a value.
The problem I have is that external function call in this library excepts IP Address in form of a byte array.
Here is the syntax for the function I am calling through my program
int createDevice (byte[] ipAddress).
now my problem is I don't know how to convert the string IPAddr variable into a byte[] ipAddress to pass it through method.Class InetAddress has a method
byte[] getAddress() You can create an instance using the static method getByName() providing the IP address string as argument.
Maybe you are looking for
-
NullPointerException because HttpSession is NULL in new Browerwindow
Hi all, we are running a jsp as portlet. Following a Link on the jsp site, a new browser window gets opened via java script. The url of the new window points a servlet in the same web application archive as the jsp. In IAS90201 HttpSession for jsp an
-
Serial key unfound Adobe CS6 install help
Please email <Removed by Moderator> having trouble locating serial on old laptop to install Adobe CS6 on my work PC. 4018212200 -Julian S,
-
Date type-specific Customizing missing for date type ACTActPln
Hi all. I'm using a Web Service obtained by copying the CRM 7.0 built-in WS APPTACTCRTRC. I'm using it to create Appointments using an Adobe Interactive Form. It goes everything fine (a Date is created in the system, with all the input data properly
-
00000001.422 File err in Premiere Pro CC
Hello all My english bad, but i will try. I want do timelapse with my Canon 600D with Magic Lantern. Problem, when i go my Premiere i can't paste and use my flies 00000001.422 00000002.422 .... I do my timelapse with silent in Magic Lantern. Anyone k
-
I have a new i phone6 and cant watch the photos i had in my old iphone 4- i can see in the i cloud a line showing last backup of my old i phone 4 but can't see the pictures i have there - tnx for the support