Help to convert program to pseudocode. My program is listed below. // Constant f
ID: 3555619 • Letter: H
Question
Help to convert program to pseudocode. My program is listed below.
// Constant for Array Size of Account Numbers
Constant Integer SIZE = 18
// Array to hold the charge account numbers
Declare integer acctnumbers[SIZE] = { 5658845, 4520125, 7895122, 8777541, 8451277, 1302850,8080152, 4562555, 5552012, 5050552, 7825877, 1250255, 1005231, 6545231, 3852085, 7576651, 7881200, 4581002};
Declare Integer account;
Declare Integer counter;
Declare bool found = false;
Display "Please enter the Charge Account Number to search for:";
Input account;
// Sequential Search
For (counter = 0; counter < 18; counter++)
if (account == acctnumbers[counter])
{
found = true;
Display "The Charge Account Number is valid ";
}
else
{
Display "The Charge Account Number is not valid ";
{
break;
}
End For
return 0;
}
Explanation / Answer
package abc;
public class chegg1 {
public static void main(String[] args) {
int SIZE=18;
int acctnumbers[]={ 5658845, 4520125, 7895122, 8777541, 8451277, 1302850,8080152, 4562555, 5552012, 5050552, 7825877, 1250255, 1005231, 6545231, 3852085, 7576651, 7881200, 4581002};
int account;
int counter;
boolean found = false;
System.out.println("Please enter the Charge Account Number to search for:");
account=Integer.parseInt(args[0]);
for (counter = 0; counter < 18; counter++)
{
if (account == acctnumbers[counter])
{
found = true;
System.out.println("The Charge Account Number is valid ");
}
else
{
System.out.println("The Charge Account Number is not valid ");
{
break;
}
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.