Programming :: How To Tell Java To Print 20 When Value Is In That Range
Jul 28, 2011
I've just started programming at my university and I'm finding it a bit hard to get started. I've been given this for homework.Given 2 integers, a and b, print their sum. However, sums in the range 10..19 inclusive, are forbidden, so in that case just print 20The problem I'm having is that i don't know how to tell java to print 20 when the value is in that range.
View 14 Replies
ADVERTISEMENT
Jun 14, 2011
From a file I want to extract a range of lines by patterns. I've used variations on
Code:
sed -n -e '/^BashNotes/,/^EndOf[A-Za-z]*$/ p' -e '/^EndOf[A-Za-z]*$/ q' Notes
So, I want to extract lines starting from one whose first word is specified, in this case "BashNotes", and ending at the first line consisting of the single word "EndOf...", which in this case would be "EndOfBashNotes".
Either I get no output at all, or it prints from the start of file to the first EndOf..., so the problem has to be with "^BashNotes", e.g. remove the "^" and it accesses an earlier occurrence of "BashNotes" that is in the middle of the first line of the file, and prints to the first occurrence of "EndOf...".
So why should a "^" in the "from" pattern be objectionable, when it is acceptable in the "to" pattern and the "quit" statement?
View 7 Replies
View Related
Nov 6, 2010
Program in CSay I have a char array of 1024 bytes called buf1.But I only want to print the chars in index 0 up to index 30. I know I could do this with a for loop. But is there any other way? What about maybe storing from 31-1024 to another char array say buf2 with strcpy and somehow popping 31+ out of the buf1 char array?
View 3 Replies
View Related
Nov 4, 2010
How can i print the biggest float and biggest double exponential notation in Java ?
View 1 Replies
View Related
Apr 11, 2011
I want to build a bash script, which can ping a range IP adresses which will be filled in by the admin. If there is no IP-adress filled in, then the script must ping the subnet where the system is logged on. So if my ip is 192.168.1.6, then the script must ping from 192.168.1.1 till 192.168.1.255 Or else, if there is given a beginning and ending ip it must ping that!
The first part of the bash script is to ping a given range (see below). But there is one problem, how can I tell the script to ping from $begin till $end, [..] is of course wrong! But what must be filled in there???
echo "Enter beginning IP-adres:"
read begin
echo "Enter ending IP-adres:"
read end
ping -c 1 $begin [..] $end
The second part is to find my own ip and ping the whole range.. How to do that? I only can find my own IP, but I cant ping the whole range,, how to do that?
#!/bin/bash
ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' |
cut -d: -f2 | awk '{ print $1 }'
View 11 Replies
View Related
Feb 23, 2011
I must say I am newby using Fedora, but cannot find solution how to define print range in calc. I am using oo for almost ten years in windoze, but this is first time I have this problem. I'm using Fedora 14 L, on my lap compaq 6715b. During install, everything went just fine, only problem in last month, since I install F14 L I have find, was using oo calc. I need that rather quickly because I need to apply my tax income until end february,
View 3 Replies
View Related
Mar 20, 2011
I'm not really a C++ noob at all, but I am a little rusty at the moment. Still, I CANNOT figure out what is wrong with the following code. I'm using Visual Studio 2010.
Code: #include <iostream>
#include <fstream>
#include <vector>
#include <string>
[Code]....
I THINK I got all of the pertinent code. Anyway, it fails at the *** line. I CANNOT figure out why. If I modify it to be linein.size()-30, it STILL gives me an error. That makes zero sense.
View 3 Replies
View Related
Jun 23, 2009
get me understand the short range and the long range links from routing (and routing protocols') point of view.
View 6 Replies
View Related
Apr 24, 2011
I want to plot a set of data in only one plot.The problem is that some points of the data should be better plotted in a linear scale (lets say 0 to 100,000) but there are other data points that, exceding the value 100,000, would be better plotted in a logarithmic scale, as they goes in the range 100,000 to 500,000,000. Let's say the data is:
Code:
X Y
0 100
10000 80
20000 75
[code]....
Is there a way to plot all these points in the same plot in only one X-axis showing two different ranges in that axis: linear: 0-100,000 logarithmic: 100,000 - 1,000,000,000?The axis would be read, for example, as:
Code:
|-----|-----|-----|-----|-----|-----|-----|-----|-----|
0 20k 40k 60k 80k 100k 1M 10M 100M 1G
(The abbreviations k-M-G are not the important point. Just shown for clarity)
View 2 Replies
View Related
Aug 13, 2010
I have 50 files in the following format.
fileone.0001.txt
filetwo.0002.txt
filethree.0003.txt
[code]...
View 4 Replies
View Related
Mar 8, 2010
I have a hard time figuring this out. I need to replace the date formats of arrival date(column 31-40) and departure date(column 42-51) and I need 2 outputs. I cannot even figure out how to start.code...
View 6 Replies
View Related
Feb 20, 2010
Feel free to just link to another thread where this is (pre)solved; I can't search the forum for the word "for," because it's too short (or maybe the search engine dislikes prepositions).
Is there a way to give the 'for' command a range? Here's what I mean:
Code:
#for i in (1-5); do echo $i; done
Certainly, meat space user; I understand exactly what you're thinking.
1
2
3
4
5
True, I realize I could use
Code:
COUNT=1 ; while [ $COUNT -lt 6 ]...
...but if I can avoid the extra preparatory step I'd prefer to do so.
View 2 Replies
View Related
Jan 28, 2010
I am fairly new to bash scripting, and I am trying to test a variable against a number range (1-3). This is what I have used so far: The user enters a value, then
while [ "$PROV" != "1" ] && [ "$PROV" != "2" ] && [ "$PROV" != "3" ] && [ $COUNTER -lt 4 ] || [ -z "$PROV" ] && [ $COUNTER -lt 4 ]; do
clear
echo
[code]....
Is there a cleaner way to do this? Something like:
while [ "$PROV" != "1-3" ]&& [ $COUNTER -lt 4 ] || [ -z "$PROV" ] && [ $COUNTER -lt 4 ]; do
View 3 Replies
View Related
Apr 13, 2011
I'm looking for a c++ code that search for all files in computer between two input dates (example- 3.3.2011 and 11.4.2011)and copy all file in that range in new file .the user run the program and input date and path in dos system
View 8 Replies
View Related
Jul 1, 2011
In the MySQL database for one of my programming projects, I used a "YEAR(4)", because I wanted the column to contain four-digit year values. I discovered, though, that this type only allows values from 1901 to 2155, which is not workable as some year values are previous to the twentieth century. But I do not want a "DATE" type because the month and day are of no interest to me. What type should I convert to that would be the least radical change in data type, while giving more range?
View 1 Replies
View Related
Dec 7, 2010
I have data that looks similar to this -
Quote:
John Smith (Address)
123 Main St
Unit 1
[code].....
So I need everything between each name, but I am not guaranteed that each time I match a name that I will have the same amount of lines, so I do a range pattern search line this to get all lines, no matter if there is 5 or 10 or 15. I simply do a loop that goes through the whole array until I hit the match, and this is my search pattern.
Code:
if ($LINE =~ /^s+$SELECTED_NAME/ ... $LINE =~ /(Address)/) {
push @ADDRESS_INFO, $LINE;
}
This works perfectly... until I hit the end and it doesn't get its final pattern match because it's at the end and there is no next entry with a (Address) line. So as a 'hack', I ended up inserting a final scalar at the end of the array that just says (Address) so it knows it's at the end. Ideally though, I'd like to do an "or" statement that says search for Address || return true if I hit the end of the array. How would I match on "End Of Array" essentially?
View 1 Replies
View Related
Jul 30, 2010
adf 32 324 100 100 24 234I want a gawk statement to match the above line if lets sayand field between 4 and 6 == 100.
View 2 Replies
View Related
Feb 18, 2011
Having a bit of an issue with Python while trying to write a script to download every rar file on a webpage. The script successfully downloads any link that doesn't contain any spaces, etc. But when it hits a url like: [URL] (Classical Spelling).rar. It fails...I'm sure this is something simple, but I'm so new to python I'm not sure what to do!
Code:
import urllib2
import os
os.system("curl [URL] -i rar|cut -d '"' -f 2 > temp.out ")
infile =open('temp.out', 'r')
for url in infile:
print url
#url = "[URL]"
#url = target
file_name = url.split('/')[-1]
u = urllib2.urlopen(url)
f = open(file_name, 'w')
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
print "Downloading: %s Bytes: %s" % (file_name, file_size)
file_size_dl = 0
block_sz = 8192
while True:
buffer = u.read(block_sz)
if not buffer:
break
file_size_dl += block_sz
f.write(buffer)
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
status = status + chr(8)*(len(status)+1)
print status,
f.close()
View 7 Replies
View Related
Mar 7, 2010
Groovy is an object-oriented programming language for the Java platform. I do not have experience in Java, only perl and shell scripts. Recently I have been asked to maintain a software written in groovy (also to make enhancements). So can I learn groovy without knowing java language. or isit I have to learn java before venturing into groovy.
View 1 Replies
View Related
Nov 19, 2008
I'm having a bit of trouble with a regular expression I'm trying to write and I'm not sure if it's something Tcl specific or my lack of regexp understanding.
[Code]...
I get a number of strings passed to a proc in the format 3|x where x is a number, either 0 or within the range 5-12. My understanding is that that regexp will match the literal '3' followed by a '|', the escapes the special meaning of |, and then 0 or, because of |, a number within the range 5-12. However I'm getting the error 'couldn't compile regular expression pattern: invalid character range'.
View 3 Replies
View Related
Jun 24, 2010
I want to print NaN value in a file containing of 3600 rows and 7 columns.The illustration of output file which I want to is as follows :
NaN NaN NaN NaN NaN NaN NaN (the first row)
NaN .... NaN
.
.
.
NaN .... NaN (the 3600 rows)
I tried to use below command
awk 'BEGIN {for(i = 1; i <= 3600; i++); printf "%s", "NaN", $1" "$2" "$3" "$4" "$5" "$6" "$7}' > output
Unfortunately, I couldn't get what I want to.
View 6 Replies
View Related
Apr 12, 2010
I have this code:
How can I print &FARAchieved to a file? Or, printing the whole bioReturn would be fine too.
View 8 Replies
View Related
Feb 21, 2010
Say I have a line like such:
Code:
today 2010 Feb 21 test10, 12AM
How would I print everything AFTER "2010 Feb 21 "?
What I thought to do so far is to set a variable to the format used in the string like so:
Code:
date="$(date +%Y %b %e)"
So I know I have to use either awk, sed, or perhaps bash substrings to work with the variable $date, but as to how, I'm drawing a blank.
View 5 Replies
View Related
May 16, 2011
problem statement:
pattern_search="Exam Name"
sed -n "/$pattern_search/,/hello/"p tmp5 | awk '{if ( $4 != 0 && $4 ~ /[0-9]+.*[0-9]*/ ) print "$pattern_search" " " $0 }'
"tmp5" is a file. this is printing output as
$pattern_search value1
i.e value of $pattern_search is not getting substituted. i am expecting output as
Exam Name value1
View 3 Replies
View Related
Sep 14, 2010
I have a site which will have, for example, a login system where people have to enter their usernames and passwords, depending on which they'll be let in to the site. So, in code, I've got a line like:
if ($_POST['password'] == $password) {
then do whatever
}
else { print "Wrong password" ; )
My problem is, this "Wrong password" printing is just a solitary line, not keeping with the colours and style of the site, and it looks very bad. I want to ideally, output some HTML, which will have a picture, and print the "Wrong password" in the font and colours I desire. Do I have to put all the HTML in a print statement, and then deal with the nightmare of escaping all the quote marks in it with a ""? Or is there a cleaner method to the whole thing? Maybe something like this -
if ($_POST['password'] == $password) {
then do whatever
}
[code]....
View 4 Replies
View Related
May 31, 2011
Any one using php program to direct lpt port print command, now i am creating one programe for mini shope that system having citizen CT-S4000 model.
View 2 Replies
View Related
Mar 9, 2011
i want to print all ASCII characters kind of like a table, but i really don't have an idea of how to do it, i don't know if there is a built-in method or something to accomplish this, if not
View 2 Replies
View Related
Aug 17, 2010
I am trying to write a program that monitors when an lp or basically any sort of print command is issued. If a print command is detected I want to pause that job and ask the user if he / she wants to continue.
This program would run in the background all the time so it can't sit and eat up a lot of cpu. I tried a simple while loop that continuously monitored "ps" and that obviously boosted my cpu to 100%.
View 1 Replies
View Related
Feb 26, 2009
I want to write a script that returns me name of the files that begin with the specified characters. like
Script out should be
View 3 Replies
View Related
Feb 3, 2010
how do i combine these two lines to output all network interfaces on my machine?
View 1 Replies
View Related