473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

many inputs

281 100+
good day all!
Need to consult about input array in main.
I have one program that need two inputs (a & b) in main. Please see codes below:
Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args) 
  2.     {        
  3.         try 
  4.         {          
  5.           String[] arrayArgs = new String[] { "560", "15 }; //input array
  6.           new Euclid(arrayArgs);
  7.         } 
  8.         catch (BigAlException e) 
  9.         {
  10.             System.err.println(e.getMessage());
  11.             System.exit(1);
  12.         }
  13.     }
  14.  
  15.  public Euclid(String[] arrayArgs) throws BigAlException 
  16.     {
  17.         int opcode = GCD; 
  18.  
  19.         BigInteger b1=null, b2=null;
  20.         String out="";
  21.  
  22.         b2 = receiveNumber(arrayArgs[1]);
  23.         b1 = receiveNumber(arrayArgs[0]);
  24.  
  25.          switch (opcode) 
  26.          {           
  27.             case GCD:       out = b1.gcd(b2).toString();
  28.                                   break;
  29.             default:           throw new BigAlException("invalid operation");
  30.         }                            
  31.           System.out.println(out);     }       
  32.  
  33.  
  34.  
My question, can I assign many inputs (a & b) in my main method?
such this:
Expand|Select|Wrap|Line Numbers
  1. String[] arrayArgs = new String[] { "560", "15" }; //first pair input
  2. arrayArgs[] = new String[] { "20", "23" }; // second pair
  3. arrayArgs[] = new String[] { "66", "2" }; //third
  4. arrayArgs[] = new String[] { "50", "1000" }; 
  5. arrayArgs[] = new String[] { "8", "235" }; 
  6. ....//until 1000 pair inputs
I need to run about 1000 pairs of input.
It takes long time to do one by one to check their result. Kindly please advisme...Thank You.
Apr 26 '07 #1
7 1660
r035198x
13,262 8TB
good day all!
Need to consult about input array in main.
I have one program that need two inputs (a & b) in main. Please see codes below:
Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args) 
  2. try 
  3. String[] arrayArgs = new String[] { "560", "15 }; //input array
  4. new Euclid(arrayArgs);
  5. catch (BigAlException e) 
  6. {
  7. System.err.println(e.getMessage());
  8. System.exit(1);
  9. }
  10. }
  11.  
  12. public Euclid(String[] arrayArgs) throws BigAlException 
  13. {
  14. int opcode = GCD; 
  15.  
  16. BigInteger b1=null, b2=null;
  17. String out="";
  18.  
  19. b2 = receiveNumber(arrayArgs[1]);
  20. b1 = receiveNumber(arrayArgs[0]);
  21.  
  22. switch (opcode) 
  23. case GCD: out = b1.gcd(b2).toString();
  24. break;
  25. default: throw new BigAlException("invalid operation");
  26. System.out.println(out); } 
  27.  
  28.  
  29.  
My question, can I assign many inputs (a & b) in my main method?
such this:
Expand|Select|Wrap|Line Numbers
  1. String[] arrayArgs = new String[] { "560", "15" }; //first pair input
  2. arrayArgs[] = new String[] { "20", "23" }; // second pair
  3. arrayArgs[] = new String[] { "66", "2" }; //third
  4. arrayArgs[] = new String[] { "50", "1000" }; 
  5. arrayArgs[] = new String[] { "8", "235" }; 
  6. ....//until 1000 pair inputs
I need to run about 1000 pairs of input.
It takes long time to do one by one to check their result. Kindly please advisme...Thank You.
You can use a for loop.

Or maybe I didn't get your question right ...
Apr 26 '07 #2
shana07
281 100+
You can use a for loop.

Or maybe I didn't get your question right ...
Yes, you're right. But then to use loop, where to start? I mean because I already have array for those 2 inputs:
Expand|Select|Wrap|Line Numbers
  1. b2 = receiveNumber(arrayArgs[1]);
  2.         b1 = receiveNumber(arrayArgs[0]);
hope you can give some pointers how to start...many thanks
Apr 26 '07 #3
r035198x
13,262 8TB
Yes, you're right. But then to use loop, where to start? I mean because I already have array for those 2 inputs:
Expand|Select|Wrap|Line Numbers
  1. b2 = receiveNumber(arrayArgs[1]);
  2. b1 = receiveNumber(arrayArgs[0]);
hope you can give some pointers how to start...many thanks
Where are the numbers coming from?
Apr 26 '07 #4
shana07
281 100+
Where are the numbers coming from?
I code them in main (wanted to skip input from command prompt):
Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args) 
  2.     {        
  3.         try 
  4.         {          
  5.              String[] arrayArgs = new String[] { "560", "12415"}; // This 1st pair (a & b) I need to input 1000 pairs (a & b)
  6.             new Euclid(arrayArgs);
  7.         } 
  8.         catch (BigAlException e) 
  9.         {
  10.             System.err.println(e.getMessage());
  11.             System.exit(1);
  12.         }
  13.     }
Apr 26 '07 #5
r035198x
13,262 8TB
I code them in main (wanted to skip input from command prompt):
Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args) 
  2. try 
  3. String[] arrayArgs = new String[] { "560", "12415"}; // This 1st pair (a & b) I need to input 1000 pairs (a & b)
  4. new Euclid(arrayArgs);
  5. catch (BigAlException e) 
  6. {
  7. System.err.println(e.getMessage());
  8. System.exit(1);
  9. }
  10. }
How about something along the lines of
Expand|Select|Wrap|Line Numbers
  1.  for(int i = 0; i < 1000; i++) { 
  2.        System.out.println("Enter the vaue a" + (i + 1));
  3.        String a = scanner.next();
  4.        System.out.println("Enter the vaue b" + (i + 1));
  5.        String a = scanner.next();  
  6.        String[] arrayArgs = new String[] { a, b}; // This 1st pair (a & b) I 
  7.        new Euclid(arrayArgs);
  8.  } 
  9.  
  10.  
Apr 26 '07 #6
shana07
281 100+
How about something along the lines of
Expand|Select|Wrap|Line Numbers
  1.  for(int i = 0; i < 1000; i++) { 
  2.        System.out.println("Enter the vaue a" + (i + 1));
  3.        String a = scanner.next();
  4.        System.out.println("Enter the vaue b" + (i + 1));
  5.        String a = scanner.next();  
  6.        String[] arrayArgs = new String[] { a, b}; // This 1st pair (a & b) I 
  7.        new Euclid(arrayArgs);
  8.  } 
  9.  
  10.  
Thank You ..it works!
Apr 26 '07 #7
shana07
281 100+
Another question about reading input file from output.
I have two files that are stored inputs for the program.
A1, A2, A3, A4...., A1000 - this is under file A.txt
B1, B2, B3, B4, ..., B1000 - this is under file B.txt

These files are in this format:
330072200741363403589390174
109758248569045035184699925856796
942816176140574448138911002257131185418157
354648
......

How to convert them to binary files? I mean I need them to be converted in bytecode......any ideas? Thank you...
Apr 26 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chris Beach | last post by:
Hi there. I'd like to be able to group together inputs on an HTML form inside, say, a <div> or <fieldset> and then use javascript to iterate through the controls in the group and disable them....
11
by: Sven Neuberg | last post by:
Hi, I have been handed the task of updating and maintaining a web application, written in ASP and Javascript, that takes complex user inputs in HTML form and submits them to server-side ASP...
8
by: Luke | last post by:
I have read the artivle on how to make forms, here it is: http://www.cs.tut.fi/~jkorpela/forms/choices.html For radio group buttons i would do : var buttonGroup = document.forms.elements; for...
6
by: Mike | last post by:
I have a form that contains 240 "products". Each Product has a TR. Each TR contains a Yes and No radio button and a Product-Qty text input. A situation exists where I have to go through all the...
18
by: shana07 | last post by:
Hi All, I do really need to consult you guys about my java assignment. Please guide me how to make an algorithm to select an input from a set of inputs? Suppose I have a program p (a), an...
2
by: mauricesmith42 | last post by:
Sorry i know this is rather large to be posting, but in order to understand the question you have to see all the code //#include <windows.h> //needed for opening folders #include...
1
by: dawidg | last post by:
I have an asp.net page with viewstate disabled. I have a control on the page that dynamically creates controls inside itself, no viewstate. The controls aren't created in Init, but in Load. With...
7
by: stevewy | last post by:
I'm looking to manipulate/check the state of various checkboxes and radios in a form. Because I don't want to access all of the checkboxes in the form, only a specific section, I am trying to...
1
by: Tonie | last post by:
this is my current layout. 4 tables each with difrent inputs table 1-- Own Form. table 2-- Own Form. table 3-- Own Form. table 4-- Own Form. then i want to link the user to property each...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.