COIT20245 : Introduction To Programming - UML Activity -Syntax Error - Human Computer Interaction Assignment Help

Download Solution Order New Solution

Introduction To Programming  Assignment Help

TASK1 1. What is the output of the following program? public class InterestCalculator { public static void main( String [ ] args ) { final int ACCOUNT=10; double interest=0, balance=0; for (int i=0; i<ACCOUNT; i++) { if ((i >=7 ) && (i<10) ) { System.out.println("The interest is: " +interest); balance=balance+10; interest=0.5*balance; } } } } 2.Draw a UML activity diagram for the program in Question 1. 3. What is the output of the following program? public class OperatorTesting { public static void main( String[ ] args ) { int number=9; if ( ( number / 2 ) == 4.5 ) System.out.print( "A \n" ); else System.out.print( "B \n" ); if  ( ++number != 9 ) System.out.print( "C \n" ); else System.out.print( "D \n" ); if  ( ( number % 3 ) == 3 ) System.out.println( "E \n " ); else System.out.println( "F \n " ); } } 4. Inspect the following program code and correct the 3 errors (syntax and logical errors) by stating the line number and then rewriting the line with the error corrected. You do NOT have to rewrite the whole program.
  • /This line is forcomments
  • importutil.Scanner;
  • public class MyProg 4 {
public static Void main( String [ ] args ) 6 {
  • Int num1=0,num2=0;
  • Scanner inputNum = new Scanner( System.in);
  • num1 = inputNum.nextInteger(); num2=num1+10; 10 }
} 5. Identify the syntax error(s), if any, in each of the following declarations. Rewrite the declaration with the error corrected. If there is no error, please write “no error”. double [ ] realVal = new double [10.5]; int[] idNum= {23411, 22315, 4456};
  • char [] myName ={'tom'};
  • ArrayList <String> myName = newArrayList<45>();
  • String [] myCity ={'Bris', 'Syd','Mel'};
 double [3][3] my2dArray = { { 1.4, 2.3, 4.5 }, { 1.3, 2.1, 2.4 }}; TASK2 1. Assume that the following program compiles and runs. State what would be the output of the following program. public class LoopOutput { public static void main( String[ ] args ) { int num1=0, num2=0; int maxNum=8; while ( num2 < maxNum ) { num2 = num1 + 2; num1 = num2 + 1; System.out.printf( " num2 value is: %d\n", num2 ); } System.out.printf( "num1 value is: %d\n", num1 ); } } 2. Examine the following program closely and rewrite the program using good programming practice. What would be the output of this program? public class Ab {public static void main (String [] args) {String [] c = {"Rocky", "Perth", "Sydney"}; for (int i = 0; i < c.length; i++) {String c1 = c[i];for (int j = 0; j<=c1.length() - 1; j++) {System.out.print(c1.charAt(j));}System.out.println();}}} 3. Assume that the following program compiles and runs. What would be the output of this program? import java.util.ArrayList; public class ArrayListJava { public static void main(String[ ] args) { // create a new array list of strings ArrayList <String> furniture= new ArrayList<String>(); // add an item to the list furniture.add("Bed"); furniture.add("Sofa"); furniture.add("Chair"); furniture.add("Desk"); furniture.add("Table"); // remove an item from the list furniture.remove(2); // display list size and list items System.out.printf("\nList has %d %s", furniture.size(), " elements."); System.out.printf(" and list items are:"); for (String item : furniture) System.out.printf("%s ", item); //check list items if (furniture.contains( "chair" ) ) System.out.println("\nList contains word chair"); else System.out.println("\nList does not contain word chair"); String index0 = (String) furniture.get(0); System.out.println("String is " + index0); //remove and add items from/to list furniture.remove(1); furniture.remove(2); furniture.add("Bed"); // display list items System.out.printf("List items are:"); for (String item : furniture) System.out.printf("%s ", item); }// end main }// end class ArrayListJava 4. The following program uses two methods from class Arrays for sorting and searching an array. When the following program is compiled, two errors occur indicating that some methods (simpleSort and simpleSearch) cannot be found. Correct the two errors by rewriting the lines and state what would be the output of the program. import java.util.Arrays; public class ArraySortingSearching { public static void main(String[ ] args) { // declare and initialise an array int [] numberArray = {3, 55, 22, 4, 6, 10, 33}; // sort and display numberArray Arrays.simpleSort(numberArray); System.out.printf("\nThe array in sorted order is:"); for (int i=6; i>=0; i--) System.out.printf("%d ", numberArray[i]); // find and display location for number 10 int location = Arrays.simpleSearch(numberArray, 10); if (location>=0) System.out.printf("\n Number 10 found at location: %d ", location); else System.out.printf("\n Number 10 not found "); }// end main }// end class ArraySortingSearching 5. This question is related to Human Computer Interaction (HCI).
  1. What is an expert review method? List two negative points in using expert review methods. Do not write more than four lines to answer this
  2. Why do we need golden rules of interface design? Do not write more than three lines to answer this
TASK3 1. Assume that the following program compiles and runs. What would be the output of this program? import java.util.Scanner; public class CompareStrings { public static void main( String[ ] args ) { // get strings String firstString[ ] = { "We", "Go", "to", "Rocky", "Grammar","School" }; String secondString[ ] ={ "I", "go", "To", "Perth", "State", "School" }; // compare strings for ( int j = 0; j < 6; j++ ) { boolean svalue=firstString[j].startsWith("Sc"); int value = firstString[j].compareTo( secondString[j] ); // display result if (!svalue) System.out.println( "\nCompare Result:" ); if (( value == 0 ) && (!svalue)) System.out.printf( "%s == %s\n", firstString[j], secondString[j] ); if (( value > 0 ) && (!svalue)) System.out.printf( "%s > %s\n", firstString[j], secondString[j] ); if (( value < 0 ) && (!svalue)) System.out.printf( "%s < %s\n", firstString[j], secondString[j] ); }// end for }// end main }// end class CompareStrings 2. This question is related to Human Computer Interaction (HCI).
  • What is a participatory design? List two negative points for using a participatory design. Do not write more than four lines to answer this
  • List two principles of interactive systems.Do not write more than two lines to answer this
3. The program below reads a file name from the keyboard which contains names (see sample file format below), opens the file, reads names from the file, displays the names, counts the number of names in the file that starts with a character D and displays the counter. Inspect the following program code and complete the program code for the required programming task. You do NOT have to rewrite the whole program. Write only the missing code. Sample file format: Peter Brown Pat Rafter David Warner import java.util.Scanner; import java.io.*; public class NameAnalysis { public static void main (String [ ] args) throws IOException { int nameCounter=0; Scanner rInput = new Scanner (System.in); //Get the file name System.out.print("Enter the file name: "); String fName = rInput.nextLine(); //Open the file /*** Write Missing Code ***/ Scanner inFile = new Scanner(filePt); while (inFile.hasNext()) { //Read and display the name /*** Write Missing Code ***/  //Display the name if it starts with a character D and update counter /*** Write Missing Code ***/ } //Display the total number of names in the file that starts with a character D /*** Write Missing Code ***/ //Close the file inFile.close(); }//end of main method }//end of class NameAnalysis
The above question has been Introduction To Programming solved by our experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
   

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.