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: - public static void main(String[] args)
-
{
-
try
-
{
-
String[] arrayArgs = new String[] { "560", "15 }; //input array
-
new Euclid(arrayArgs);
-
}
-
catch (BigAlException e)
-
{
-
System.err.println(e.getMessage());
-
System.exit(1);
-
}
-
}
-
-
public Euclid(String[] arrayArgs) throws BigAlException
-
{
-
int opcode = GCD;
-
-
BigInteger b1=null, b2=null;
-
String out="";
-
-
b2 = receiveNumber(arrayArgs[1]);
-
b1 = receiveNumber(arrayArgs[0]);
-
-
switch (opcode)
-
{
-
case GCD: out = b1.gcd(b2).toString();
-
break;
-
default: throw new BigAlException("invalid operation");
-
}
-
System.out.println(out); }
-
-
-
My question, can I assign many inputs (a & b) in my main method?
such this: - String[] arrayArgs = new String[] { "560", "15" }; //first pair input
-
arrayArgs[] = new String[] { "20", "23" }; // second pair
-
arrayArgs[] = new String[] { "66", "2" }; //third
-
arrayArgs[] = new String[] { "50", "1000" };
-
arrayArgs[] = new String[] { "8", "235" };
-
....//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.
7 1660
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: - public static void main(String[] args)
-
{
-
try
-
{
-
String[] arrayArgs = new String[] { "560", "15 }; //input array
-
new Euclid(arrayArgs);
-
}
-
catch (BigAlException e)
-
{
-
System.err.println(e.getMessage());
-
System.exit(1);
-
}
-
}
-
-
public Euclid(String[] arrayArgs) throws BigAlException
-
{
-
int opcode = GCD;
-
-
BigInteger b1=null, b2=null;
-
String out="";
-
-
b2 = receiveNumber(arrayArgs[1]);
-
b1 = receiveNumber(arrayArgs[0]);
-
-
switch (opcode)
-
{
-
case GCD: out = b1.gcd(b2).toString();
-
break;
-
default: throw new BigAlException("invalid operation");
-
}
-
System.out.println(out); }
-
-
-
My question, can I assign many inputs (a & b) in my main method?
such this: - String[] arrayArgs = new String[] { "560", "15" }; //first pair input
-
arrayArgs[] = new String[] { "20", "23" }; // second pair
-
arrayArgs[] = new String[] { "66", "2" }; //third
-
arrayArgs[] = new String[] { "50", "1000" };
-
arrayArgs[] = new String[] { "8", "235" };
-
....//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 ...
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: - b2 = receiveNumber(arrayArgs[1]);
-
b1 = receiveNumber(arrayArgs[0]);
hope you can give some pointers how to start...many thanks
Yes, you're right. But then to use loop, where to start? I mean because I already have array for those 2 inputs: - b2 = receiveNumber(arrayArgs[1]);
-
b1 = receiveNumber(arrayArgs[0]);
hope you can give some pointers how to start...many thanks
Where are the numbers coming from?
Where are the numbers coming from?
I code them in main (wanted to skip input from command prompt): - public static void main(String[] args)
-
{
-
try
-
{
-
String[] arrayArgs = new String[] { "560", "12415"}; // This 1st pair (a & b) I need to input 1000 pairs (a & b)
-
new Euclid(arrayArgs);
-
}
-
catch (BigAlException e)
-
{
-
System.err.println(e.getMessage());
-
System.exit(1);
-
}
-
}
I code them in main (wanted to skip input from command prompt): - public static void main(String[] args)
-
{
-
try
-
{
-
String[] arrayArgs = new String[] { "560", "12415"}; // This 1st pair (a & b) I need to input 1000 pairs (a & b)
-
new Euclid(arrayArgs);
-
}
-
catch (BigAlException e)
-
{
-
System.err.println(e.getMessage());
-
System.exit(1);
-
}
-
}
How about something along the lines of - for(int i = 0; i < 1000; i++) {
-
System.out.println("Enter the vaue a" + (i + 1));
-
String a = scanner.next();
-
System.out.println("Enter the vaue b" + (i + 1));
-
String a = scanner.next();
-
String[] arrayArgs = new String[] { a, b}; // This 1st pair (a & b) I
-
new Euclid(arrayArgs);
-
}
-
-
How about something along the lines of - for(int i = 0; i < 1000; i++) {
-
System.out.println("Enter the vaue a" + (i + 1));
-
String a = scanner.next();
-
System.out.println("Enter the vaue b" + (i + 1));
-
String a = scanner.next();
-
String[] arrayArgs = new String[] { a, b}; // This 1st pair (a & b) I
-
new Euclid(arrayArgs);
-
}
-
-
Thank You ..it works!
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...
Sign in to post your reply or Sign up for a free account.
Similar topics
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....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
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...
|
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,...
|
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,...
|
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...
| |