Search Results

Search found 5942 results on 238 pages for 'total starnger'.

Page 51/238 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • Question about InputMismatchException while using Scanner

    - by aser
    The question : Input file: customer’s account number, account balance at beginning of month, transaction type (withdrawal, deposit, interest), transaction amount Output: account number, beginning balance, ending balance, total interest paid, total amount deposited, number of deposits, total amount withdrawn, number of withdrawals package sentinel; import java.io.*; import java.util.*; public class Ex7 { /** * @param args the command line arguments */ public static void main(String[] args) throws FileNotFoundException { int AccountNum; double BeginningBalance; double TransactionAmount; int TransactionType; double AmountDeposited=0; int NumberOfDeposits=0; double InterestPaid=0.0; double AmountWithdrawn=0.0; int NumberOfWithdrawals=0; boolean found= false; Scanner inFile = new Scanner(new FileReader("Account.in")); PrintWriter outFile = new PrintWriter("Account.out"); AccountNum = inFile.nextInt(); BeginningBalance= inFile.nextDouble(); while (inFile.hasNext()) { TransactionAmount=inFile.nextDouble(); TransactionType=inFile.nextInt(); outFile.printf("Account Number: %d%n", AccountNum); outFile.printf("Beginning Balance: $%.2f %n",BeginningBalance); outFile.printf("Ending Balance: $%.2f %n",BeginningBalance); outFile.println(); switch (TransactionType) { case '1': // case 1 if we have a Deposite BeginningBalance = BeginningBalance + TransactionAmount; AmountDeposited = AmountDeposited + TransactionAmount; NumberOfDeposits++; outFile.printf("Amount Deposited: $%.2f %n",AmountDeposited); outFile.printf("Number of Deposits: %d%n",NumberOfDeposits); outFile.println(); break; case '2':// case 2 if we have an Interest BeginningBalance = BeginningBalance + TransactionAmount; InterestPaid = InterestPaid + TransactionAmount; outFile.printf("Interest Paid: $%.2f %n",InterestPaid); outFile.println(); break; case '3':// case 3 if we have a Withdraw BeginningBalance = BeginningBalance - TransactionAmount; AmountWithdrawn = AmountWithdrawn + TransactionAmount; NumberOfWithdrawals++; outFile.printf("Amount Withdrawn: $%.2f %n",AmountWithdrawn); outFile.printf("Number of Withdrawals: %d%n",NumberOfWithdrawals); outFile.println(); break; default: System.out.println("Invalid transaction Tybe: " + TransactionType + TransactionAmount); } } inFile.close(); outFile.close(); } } But is gives me this : Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:840) at java.util.Scanner.next(Scanner.java:1461) at java.util.Scanner.nextInt(Scanner.java:2091) at java.util.Scanner.nextInt(Scanner.java:2050) at sentinel.Ex7.main(Ex7.java:36) Java Result: 1

    Read the article

  • MongoDb - $match filter not working in subdocument

    - by Ranjith
    This is Collection Structure [{ "_id" : "....", "name" : "aaaa", "level_max_leaves" : [ { level : "ObjectIdString 1", max_leaves : 4, } ] }, { "_id" : "....", "name" : "bbbb", "level_max_leaves" : [ { level : "ObjectIdString 2", max_leaves : 2, } ] }] I need to find the subdocument value of level_max_leaves.level filter when its matching with given input value. And this how I tried, For example, var empLevelId = 'ObjectIdString 1' ; MyModel.aggregate( {$unwind: "$level_max_leaves"}, {$match: {"$level_max_leaves.level": empLevelId } }, {$group: { "_id": "$level_max_leaves.level", "total": { "$sum": "$level_max_leaves.max_leaves" }}}, function (err, res) { console.log(res); }); But here the $match filter is not working. I can't find out exact results of ObjectIdString 1 If I filter with name field, its working fine. like this, {$match: {"$name": "aaaa" } }, But in subdocument level its returns 0. {$match: {"$level_max_leaves.level": "ObjectIdString 1"} }, My expected result was, { "_id" : "ObjectIdString 1", "total" : 4, }

    Read the article

  • Facebook insights for websites does not match on-site Facebook button counts

    - by Will
    I use Facebook Insights for websites and Facebook buttons on my site. However, the data reported by the two do not match. It always seems to be the case that the count reported by the buttons is significantly higher than the count reported in Facebook Insights. For example, this page http://www.appmyworld.com/blog/top-5-iphone-and-ipad-apps-of-the-week-10412.html has a count of 52 for Facebook which is made up of 19 likes, 21 shares and 12 comments according to AddThis and confirmed by http://sharedcount.com However, going into Facebook Insights for my website and looking at that specific page it shows only 4 total actions which is made up of 1 like and 3 shares. At the very least I would expect it to show a total count of 40 made up of 19 likes and 21 shares (I'm not sure it would track the 12 comments). Any thoughts on why this may be happening? My concern is if our website is not getting credit for the Facebook activity?

    Read the article

  • SQL Server adding a record record manually to a view

    - by SelectDistinct
    I have a view which contains the data seen in the image below. The view is showing me how many working days are available in each month for the current financial year taking away any school/bank holidays. As the month of August has zero days available it has excluded this month from the view. As the total number of days available will always be zero for the month of August, then it seems acceptable to hardcode the SQL to always have 0 for August, and also an April-August record which will be the same as April-July. What would be the best way to add these 2 records, and where about in the code should it be placed see example of code layout: see link (answered question) for layout of code: SQL populate total working days per month minus bank holidays for current financial year

    Read the article

  • shipping and handling fee calculation

    - by Newb
    Here is the question: Many companies normally charge a shipping and handling fee for purchases. Create a Web page that allows a user to enter a purchase price into a text box - include a JavaScript function that calculates shipping and handling. Add functionality to the script that adds a minimum shipping and handling fee of $1.50 for any purchase that is less than or equal to $25.00. For any orders over $25.00, add 10% to the total purchase price for shipping and handling, but do not include the $1.50 minimum shipping and handling fee. After you determine the total cost of the order (purchase plus shipping and handling), display it in an alert dialog box. I am beginner at JavaScript and struggling to get my code to work. It does display an alert box with the value entered by the user but doesn't add anything. Although, I don't know why the formula doesn't work. Please help. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Calculating Shipping & Handling</title> <script type="text/javascript"> /* <![CDATA[ */ var price=[]; var shipping=[]; var total=price+shipping; function calculateShipping(){ if (price <= 25){ shipping = (price + 1.5); } else { shipping = (price * 10 / 100); } window.alert("The purchase price with shipping is " + document.calculate.ent.value); } /* ]]> */ </script> </head> <body> <form name ="calculate" action="" > <p>Enter Purchase Price</p> <input type="text" name="ent" > <input type="button" name="button" value="Submit" onClick="calculateShipping()" /> </form> </body> </html>

    Read the article

  • Directory file size calculation - how to make it faster?

    - by Xinxua
    Using C#, I am finding the total size of a directory. The logic is this way : Get the files inside the folder. Sum up the total size. Find if there are sub directories. Then do a recursive search. I tried one another way to do this too : Using FSO (obj.GetFolder(path).Size). There's not much of difference in time in both these approaches. Now the problem is, I have tens of thousands of files in a particular folder and its taking like atleast 2 minute to find the folder size. Also, if I run the program again, it happens very quickly (5 secs). I think the windows is caching the file sizes. Is there any way I can bring down the time taken when I run the program first time??

    Read the article

  • Selecting items from events, as evenly spaced as possible

    - by Matt Warren
    If I have an event that happens 15 times a second (numbered 1 - 15), but I only want to process it 3 times I can choose [1], [6] and [11],. It's important that the events I process are as evenly spaced as possible and take into account wrap-around, i.e. the events are continuous 13, 14, 15, 1, 2, 3 etc. If I want 4 items the best I can do is [1], [5], [9] & [13]. Is there a general algorithm that will calculate which events I need to process given the total number of events (total) and the number to process (processAmount).

    Read the article

  • Using too much memory in C/NDK?

    - by rebeccamaher
    I've recently found out there is no hard limit to how much memory you can allocate in C/NDK on Android. This is in contrast to Java where the limit is ~24Mb. I'm working on a few apps that could greatly benefit from using about ~50Mb total. Is this far too much memory to use? Does anyone have any experience with developing apps that go above the Java limit and what impact this has across devices? Obviously, I don't want to kill all background apps by consuming too much memory and I know the Android devs suggest not using too much memory but limiting all apps to ~24Mb is very limiting to certain kinds of apps. I've seen a few Android games recently that say they use ~256Mb. I'm planning to use about 50Mb total for my app. Does this sound reasonable in terms of stability across devices that have a limit of 24Mb?

    Read the article

  • Python: Find X to Y in a list of strings.

    - by TheLizardKing
    I have a list of maybe a 100 or so elements that is actually an email with each line as an element. The list is slightly variable because lines that have a \n in them are put in a separate element so I can't simply slice using fixed values. I essentially need a variable start and stop phrase (needs to be a partial search as well because one of my start phrases might actually be Total Cost: $13.43 so I would just use Total Cost:.) Same thing with the end phrase. I also do not wish to include the start/stop phrases in the returned list. In summary: email = ['apples','bananas','cats','dogs','elephants','fish','gee'] start = 'ban' stop = 'ele' the magic here new_email = ['cats','dogs'] NOTES While not perfect formatting of the email, it is fairly consistent so there is a slim chance a start/stop phrase will occur more than once. There are also no blank elements.

    Read the article

  • Script Speed vs Memory Usage

    - by Doug Neiner
    I am working on an image generation script in PHP and have gotten it working two ways. One way is slow but uses a limited amount of memory, the second is much faster, but uses 6x the memory . There is no leakage in either script (as far as I can tell). In a limited benchmark, here is how they performed: -------------------------------------------- METHOD | TOTAL TIME | PEAK MEMORY | IMAGES -------------------------------------------- One | 65.626 | 540,036 | 200 Two | 20.207 | 3,269,600 | 200 -------------------------------------------- And here is the average of the previous numbers (if you don't want to do your own math): -------------------------------------------- METHOD | TOTAL TIME | PEAK MEMORY | IMAGES -------------------------------------------- One | 0.328 | 540,036 | 1 Two | 0.101 | 3,269,600 | 1 -------------------------------------------- Which method should I use and why? I anticipate this being used by a high volume of users, with each user making 10-20 requests to this script during a normal visit. I am leaning toward the faster method because though it uses more memory, it is for a 1/3 of the time and would reduce the number of concurrent requests.

    Read the article

  • how to aggregate this data in R

    - by stevejb
    Hello, I have a data frame in R with the following structure. > testData date exch.code comm.code oi 1 1997-12-30 CBT 1 468710 2 1997-12-23 CBT 1 457165 3 1997-12-19 CBT 1 461520 4 1997-12-16 CBT 1 444190 5 1997-12-09 CBT 1 446190 6 1997-12-02 CBT 1 443085 .... 77827 2004-10-26 NYME 967 10038 77828 2004-10-19 NYME 967 9910 77829 2004-10-12 NYME 967 10195 77830 2004-09-28 NYME 967 9970 77831 2004-08-31 NYME 967 9155 77832 2004-08-24 NYME 967 8655 What I want to do is produce a table the shows for a given date and commodity the total oi across every exchange code. So, the rows would be made up of unique(testData$date) and the columns would be unique(testData$comm.code) and each cell would be the total oi over all exch.codes on a given day. Thanks,

    Read the article

  • Sum in shell script

    - by Dinis Monteiro
    Why can't I create a sum of total words in this script? I get the result something like: 120+130 but it isn't 250 (as I expected)! Is there any reason? #!/bin/bash while [ -z "$count" ] ; do echo -e "request :: please enter file name " echo -e "\n\tfile one : \c" read count itself=counter.sh countWords=`wc -w $count |cut -d ' ' -f 1` countLines=`wc -l $count |cut -d ' ' -f 1` countWords_=`wc -w $itself |cut -d ' ' -f 1` echo "Number of lines: " $countLines echo "Number of words: " $countWords echo "Number of words -script: " $countWords_ echo "Number of words -total " $countWords+$countWords_ done if [ ! -e $count ] ; then echo -e "error :: file one $count doesn't exist. can't proceed." read empty exit 1 fi

    Read the article

  • Sales figures not displayed in form

    - by Brian Wilson
    Trying to calculate total sales for 5 items, 3 stores. Here's a s/s of what Im getting, along with my code. What am I missing/doing wrong? (p.s. It's not returning an error code in 'debug') Public Class Form1 Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click Dim ttlsales As Double 'set up array data Dim sales(,) As Integer = {{25, 64, 23, 45, 14}, {12, 82, 19, 34, 63}, {54, 22, 17, 43, 35}} Dim price() As Double = {12.0, 17.95, 95.0, 86.5, 78.0} 'mark totals Dim totals(2) As Double For store As Integer = 0 To 2 For item As Integer = 0 To 4 Next Next 'display output lstOut.Items.Add("Sales Per Store") For store As Integer = 0 To 2 lstOut.Items.Add(store + 1 & ":" & FormatCurrency(totals(store))) ttlsales += totals(store) Next lstOut.Items.Add("Total Sales: " & FormatCurrency(ttlsales)) End Sub End Class

    Read the article

  • zChaff not showing output

    - by pns
    Hello, So I downloaded the latest version of zChaff (2007), and was trying out some very simple SAT problems. But zChaff does not output the solution (variable assignments). A very simple example input: p cnf 2 2 1 2 0 1 -2 0 And what I get: c 2 Clauses are true, Verify Solution successful. Instance Satisfiable 1 -2 Random Seed Used 0 Max Decision Level 1 Num. of Decisions 2 ( Stack + Vsids + Shrinking Decisions ) 0 + 1 + 0 Original Num Variables 2 Original Num Clauses 2 Original Num Literals 4 Added Conflict Clauses 0 Num of Shrinkings 0 Deleted Conflict Clauses 0 Deleted Clauses 0 Added Conflict Literals 0 Deleted (Total) Literals 0 Number of Implication 2 Total Run Time 5.1e-05 RESULT: SAT I can see the 1 -2 on the left of "Random Seed Used", but shouldn't this be outputing the variable assignments as "v ..." ? Thanks

    Read the article

  • Help me with this java program

    - by aser
    The question : Input file: customer’s account number, account balance at beginning of month, transaction type (withdrawal, deposit, interest), transaction amount Output: account number, beginning balance, ending balance, total interest paid, total amount deposited, number of deposits, total amount withdrawn, number of withdrawals package sentinel; import java.io.*; import java.util.*; public class Ex7 { /** * @param args the command line arguments */ public static void main(String[] args) throws FileNotFoundException { int AccountNum; double BeginningBalance; double TransactionAmount; int TransactionType; double AmountDeposited=0; int NumberOfDeposits=0; double InterestPaid=0.0; double AmountWithdrawn=0.0; int NumberOfWithdrawals=0; boolean found= false; Scanner inFile = new Scanner(new FileReader("Account.in")); PrintWriter outFile = new PrintWriter("Account.out"); AccountNum = inFile.nextInt(); BeginningBalance= inFile.nextDouble(); while (inFile.hasNext()) { TransactionAmount=inFile.nextDouble(); TransactionType=inFile.nextInt(); outFile.printf("Account Number: %d%n", AccountNum); outFile.printf("Beginning Balance: $%.2f %n",BeginningBalance); outFile.printf("Ending Balance: $%.2f %n",BeginningBalance); outFile.println(); switch (TransactionType) { case '1': // case 1 if we have a Deposite BeginningBalance = BeginningBalance + TransactionAmount; AmountDeposited = AmountDeposited + TransactionAmount; NumberOfDeposits++; outFile.printf("Amount Deposited: $%.2f %n",AmountDeposited); outFile.printf("Number of Deposits: %d%n",NumberOfDeposits); outFile.println(); break; case '2':// case 2 if we have an Interest BeginningBalance = BeginningBalance + TransactionAmount; InterestPaid = InterestPaid + TransactionAmount; outFile.printf("Interest Paid: $%.2f %n",InterestPaid); outFile.println(); break; case '3':// case 3 if we have a Withdraw BeginningBalance = BeginningBalance - TransactionAmount; AmountWithdrawn = AmountWithdrawn + TransactionAmount; NumberOfWithdrawals++; outFile.printf("Amount Withdrawn: $%.2f %n",AmountWithdrawn); outFile.printf("Number of Withdrawals: %d%n",NumberOfWithdrawals); outFile.println(); break; default: System.out.println("Invalid transaction Tybe: " + TransactionType + TransactionAmount); } } inFile.close(); outFile.close(); } } But is gives me this : Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:840) at java.util.Scanner.next(Scanner.java:1461) at java.util.Scanner.nextInt(Scanner.java:2091) at java.util.Scanner.nextInt(Scanner.java:2050) at sentinel.Ex7.main(Ex7.java:36) Java Result: 1

    Read the article

  • how to set Custom attribute of NSManagedObject which is calculated from other attributes ?

    - by Kundan
    I am using core data framework to manage objects.i have an entity which has several attributes of decimal types. Among them is attribute which is mathematically calculated from other attributes. Ex :- @interface Marks : NSManagedObject { } @property (nonatomic, retain) NSDecimalNumber * answerGradeA; @property (nonatomic, retain) NSDecimalNumber * answerGradeB; @property (nonatomic, retain) NSDecimalNumber * answerGradeC; @property (nonatomic, retain) NSDecimalNumber * total; Here i want attribute total = 3xanswerGradeA + 2xanswerGradeB + 1xanswerGradeC if it is possible to do like this, then how ? please reply. Thanks in advance.

    Read the article

  • Returning multiple aggregate functions as rows

    - by SDLFunTimes
    I need some help formulating a select statement. I need to select the total quantity shipped for each part with a distinct color. So the result should be a row with the color name and the total. Here's my schema: create table s ( sno char(5) not null, sname char(20) not null, status smallint, city char(15), primary key (sno) ); create table p ( pno char(6) not null, pname char(20) not null, color char(6), weight smallint, city char(15), primary key (pno) ); create table sp ( sno char(5) not null, pno char(6) not null, qty integer not null, primary key (sno, pno) );

    Read the article

  • Log information inside a JUnit Suite

    - by Alex Marinescu
    I'm currently trying to write inside a log file the total number of failed tests from a JUnite Suite. My testsuite is defined as follows: @RunWith(Suite.class) @SuiteClasses({Class1.class, Class2.class etc.}) public class SimpleTestSuite {} I tried to define a rule which would increase the total number of errors when a test fails, but apparently my rule is never called. @Rule public MethodRule logWatchRule = new TestWatchman() { public void failed(Throwable e, FrameworkMethod method) { errors += 1; } public void succeeded(FrameworkMethod method) { } }; Any ideas on what I should to do to achieve this behaviour?

    Read the article

  • Make Sphinx quiet (non-verbose)

    - by J. Pablo Fernández
    I'm using Sphinx through Thinking Sphinx in a Ruby on Rails project. When I create seed data and all the time, it's quite verbose, printing this: using config file '/Users/pupeno/projectx/config/development.sphinx.conf'... indexing index 'user_delta'... collected 7 docs, 0.0 MB collected 0 attr values sorted 0.0 Mvalues, 100.0% done sorted 0.0 Mhits, 99.6% done total 7 docs, 159 bytes total 0.042 sec, 3749.29 bytes/sec, 165.06 docs/sec Sphinx 0.9.8.1-release (r1533) Copyright (c) 2001-2008, Andrew Aksyonoff for every record that is created or so. Is there a way to suppress that output?

    Read the article

  • Storing cvs data for further manipulation using Ruby

    - by ischnura
    I am dealing with a csv file that has some customer information (email, name, address, amount, [shopping_list: item 1, item 2]). I would like work with the data and produce some labels for printing... as well as to gather some extra information (total amounts, total items 1...) My main concern is to find the appropriate structure to store the data in ruby for future manipulation. For now I have thought about the following possibilities: multidimensional arrays: pretty simple to build, but pretty hard to access the data in a beautiful ruby way. hashes: having the email as key, and storing the information in different hashes (one hash for name, another hash for address, another hash for shopping list...) (getting the cvs data in to a Database and working with the data from ruby??) I would really appreciate your advice and guidance!!

    Read the article

  • Why does my report recalculate totals when I scroll in Access '07?

    - by andrewb
    Whenever I make a report in Access '07 and include some sort of total (whether counting or summing values), when I'm viewing the preview and scroll, the total recalculate. This is really annoying as Access takes a while (several tenths of a second) to do this, and while it does that the totals go blank. I've looked for a solution online, but I can't find this issue described anywhere. How can I stop the totals from recalculating when I scroll? I'm hoping for a simple solution that would solve this for all reports, or perhaps a simple property tweak on each report. I don't want to have to add code for every single report! I should describe the report layouts I'm using - they contain rows of data all on one page, and at times I group the rows. The number of rows aren't major, maybe around 50 a time or so.

    Read the article

  • How to use parameter variable in xslt

    - by Abbi
    Hi I am new to xslt so please let me know whats wrong with my syntax here. If I compare with a Constant value of '880.50' I get the desired result. But if I try to do the samething with parameter being passed I get nothing. The code snippet is as under. <xsl:template name="ShowJourneyLegs" > <xsl:param name="TotalFare" /> <Key4><xsl:value-of select='$TotalFare'/></Key4> <JourneyLegKeys><xsl:value-of select="/FareSearchResponse/CompleteItineraryFares/AirFare[@Total = '880.50']/JourneyLegKeys/Key[1]"/></JourneyLegKeys> <JourneyLeg><xsl:value-of select="/FareSearchResponse/CompleteItineraryFares/AirFare[@Total = '$TotalFare']/JourneyLegKeys/Key[1]"/></JourneyLeg> </xsl:template>

    Read the article

  • VB.net Need Text Box to Only Accept Numbers

    - by Rico Jackson
    I'm fairly new to VB.net (self taught) and was just wondering if someone out there could help me out with some code. I'm not trying to do anything to invovled, just have a textbox that takes numeric value from 1 to 10. I don't want it to take a string or any number above 10. If some types a word or character an error message will appear, telling them to enter a valid number. This is what I have, obviously it's not great as I am having problems. Thanks again to anyone who can help. If TxtBox.Text > 10 Then MessageBox.Show("Please Enter a Number from 1 to 10") TxtBox.Focus() ElseIf TxtBox.Text < 10 Then MessageBox.Show("Thank You, your rating was " & TxtBox.Text) Total = Total + 1 ElseIf IsNumeric(TxtBox.Text) Then MessageBox.Show("Thank you, your rating was " & ValueTxtBox.Text) End If ValueTxtBox.Clear() ValueTxtBox.Focus()

    Read the article

  • Counts of events grouped by date in python?

    - by Sologoub
    This is no doubt another noobish question, but I'll ask it anyways: I have a data set of events with exact datetime in UTC. I'd like to create a line chart showing total number of events by day (date) in the specified date range. Right now I can retrieve the total data set for the needed date range, but then I need to go through it and count up for each date. The app is running on google app engine and is using python. What is the best way to create a new data set showing date and corresponding counts (including if there were no events on that date) that I can then use to pass this info to a django template? Data set for this example looks like this: class Event(db.Model): event_name = db.StringProperty() doe = db.DateTimeProperty() dlu = db.DateTimeProperty() user = db.UserProperty() Ideally, I want something with date and count for that date. Thanks and please let me know if something else is needed to answer this question!

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >