i am trying to study for my exam in the morning and have bee

i am trying to study for my exam in the morning and have been struggling how to figure out these last few study questions. the code is in Java and is as follows:

// Consider the following arrays
       String names[] = new String[4];
       double grades[] = new double[4];
      
       names[0] = \"Smith, Mary\";        grades[0] = 87.3;
       names[1] = \"Jones, Peter\";       grades[1] = 92.5;
       names[2] = \"Palmer, Bill\";       grades[2] = 82.0;
       names[3] = \"Green, Becky\";       grades[3] = 94.7;
      
       // (4) Write statements that use a loop to print out all the grades in the form
       // Smith, Mary -- 87.3
      
       // (5) Write statements that use a loop to print out the names (and only the names)
       // of the individuals having an A (a 90 or higher)
      
       // (6) Write statements that prompts the user to enter someone\'s last name, and then
       // outputs that person\'s grade
      
       Scanner scnr = new Scanner(System.in);
      
      
       // Consider the following Tic Tac Toe board, with 1 representing an \'X\', -1
       // representing an \'O\', and a 0 representing a blank space (displayed as \'-\')
       int [][] board = { {1,0,1},
                           {0,1,0},
                           {1,0,1}                              
                       };
      
      
       // (7) Use nested for loops to display the board, which will look like this:
       //       X-X
       //       -0-
       //       X-X
      
       // (8) Use nested for loops to change all X\'s to O\'s and all O\'s to X\'s
      
   }
  
  
  
}

Solution

(4,5,6)

import java.util.*;
import java.lang.*;
import java.io.*;


class Grades
{
   public static void main (String[] args)
   {
       String names[] = new String[4];
double grades[] = new double[4];
int i;
Scanner scnr = new Scanner(System.in);
  
names[0] = \"Smith, Mary\";
grades[0] = 87.3;
names[1] = \"Jones, Peter\";   
grades[1] = 92.5;
names[2] = \"Palmer, Bill\";   
grades[2] = 82.0;
names[3] = \"Green, Becky\";
grades[3] = 94.7;

System.out.println(\"Names with their grades\");
for(i=0;i<4;i++) //statements that use a loop to print out all the grades in the form
{
    System.out.println(names[i]+\" -- \"+grades[i]);
}

System.out.println(\"\ Names with A grade\"); //statements that use a loop to print out the names of the individuals having an A (a 90 or higher)
for(i=0;i<4;i++)
{
    if(grades[i] > 90)
    System.out.println(names[i]);
}

System.out.println(\"Enter Person\'s last name\"); //statements that prompts the user to enter someone\'s last name, and then
// outputs that person\'s grade

String lastname = scnr.next();

for(i=0;i<4;i++)
{
    if(names[i].contains(lastname))
    System.out.println(grades[i]);
}


   }
}

output:

Success time: 0.06 memory: 711680 signal:0

2

import java.util.*;
import java.lang.*;
import java.io.*;


class TicTacToe
{
   public static void main (String[] args)
   {
       int [][] board = { {1,0,1},
{0,1,0},
{1,0,1}
};
int i,j;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
    if(board[i][j] == 1)
    System.out.print(\"X\");
    else if(board[i][j] == 0)
    System.out.print(\"-\");

}
System.out.println();
}

for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
    if(board[i][j] == 1)
    System.out.print(\"O\");
    else if(board[i][j] == 0)
    System.out.print(\"-\");
}
System.out.println();
}
   }
}

output:

Success time: 0.05 memory: 711168 signal:0

i am trying to study for my exam in the morning and have been struggling how to figure out these last few study questions. the code is in Java and is as follows
i am trying to study for my exam in the morning and have been struggling how to figure out these last few study questions. the code is in Java and is as follows
i am trying to study for my exam in the morning and have been struggling how to figure out these last few study questions. the code is in Java and is as follows

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site