Answer:
a) "Quit"
c) "Q only
Explanation:
Given
String s = "Go";
while ((!s.equals("q"))&& (!s.equals(""))) {
System.out.println("In loop");
s = scnr.next();
}
Required
What input causes another execution
Analyzing the while condition
while ((!s.equals("q"))&& (!s.equals("")))
This can be split into:
!s.equals("q")) && (!s.equals(""))
Meaning
When s is not equal to "q" and when s is not an empty string
In other words,
the loop will be executed when user input is not "q" and user input is not empty.
So, from the list of given options: The loop both will be executed when:
a) Input is "Quit"
c) Input is Q only
Input of q will terminate the loop, hence b and d are incorrect
Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full credit is 100, so anything over 100 is extra credit.
Question:
Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full credit is 100, so anything over 100 is extra credit. Ex: If testGrades = {101, 83, 107, 90}, then sumExtra = 8, because 1 + 0 + 7 + 0 is 8.
#include <iostream>
#include <vector>
using namespace std;
int main() {
const int NUM_VALS = 4;
vector<int> testGrades(NUM_VALS);
int i = 0;
int sumExtra = -9999; // Assign sumExtra with 0 before your for loop
testGrades.at(0) = 101;
testGrades.at(1) = 83;
testGrades.at(2) = 107;
testGrades.at(3) = 90;
/* Your solution goes here */
cout << "sumExtra: " << sumExtra << endl;
return 0;
}
Answer:
Replace /* Your solution goes here */ with the following lines of code
sumExtra = 0;
do{
if(testGrades.at(i) > 100){
sumExtra = sumExtra + (testGrades.at(i) - 100);
}
i++;
}
while(i<NUM_VALS);
Explanation:
In the complete question posted, the variables sumExtra and i have already been declared an initialized.
So, the first thing we do in the solution is:
set sumExtra to 0 using sumExtra = 0;
Then iterate through vector testGrades using i as the iterating variable
Here, I made used of a do while loop and the explanation is as follows:
do{
This line checks if current element of the vector is greater than 100
if(testGrades.at(i) > 100){
If yes, the extra digits above 100 is added to the sumExtra
sumExtra = sumExtra + (testGrades.at(i) - 100);
}
The counter is increased, here
i++;
}
The loop is continued while the iterating variable i is less than NUM_VALS which is 4
while(i<NUM_VALS);
What is payload?
a block of data inside the packet
a block of data transmitted across a network
the maximum amount of data a network can transmit
a 32-bit numeric address
Answer:
a block of data inside the packet
Lab9A: Warmup. Write a program that contains three methods: Method max (int x, int y, int z) returns the maximum value of three integer values. Method min (int X, int y, int z) returns the minimum value of three integer values. Method average (int x, int y, int z) returns the average of three integer values. Note: for Java and C#, these methods must be public and static. Prompt the user for three numbers, then call these methods from main to print out the minimum, maximum and average of numbers that the user entered. Your program should behave like the sample output below. Sample output #1 Enter number 1: 5 Enter number 2: 9 Enter number 3: 2 Min is 2 Max is 9 Average is 5.33333 Sample output 2 Enter number : 45 Enter number 2 : 11 Enter number 3: -3 Min is-3 Max is 45 Average is 17.6667
import java.util.Scanner;
import java.util.Arrays;
public class JavaApplication30 {
public static int max(int x, int y, int z){
int[] arr = {x, y, z};
Arrays.sort(arr);
return arr[2];
}
public static int min(int x, int y, int z){
int[] arr = {x, y, z};
Arrays.sort(arr);
return arr[0];
}
public static double average(int x, int y, int z){
return (double) (x + y + z) / 3;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter your first number");
int x = scan.nextInt();
System.out.println("Enter your second number");
int y = scan.nextInt();
System.out.println("Enter your third number");
int z = scan.nextInt();
System.out.println("Min is "+min(x,y,z));
System.out.println("Max is "+max(x,y,z));
System.out.println("Average is "+average(x,y,z));
}
}
I hope this helps! If you have any more questions, I'll try my best to answer them.
Which best explains the workplaces of employees in the Energy career cluster?
Employees work outdoors.
Employees can work in a wide variety of places.
Employees can work in a limited number of places.
Employees work indoors.
Answer: It’s Letter (B) the other ones just don’t fit.
Explanation:
Mark me as brainlest please?!!
Answer:
b
Explanation:
Allison is writing a program in Java and keeps getting an error. Which line of code is causing the error?
A. Int a = 0, b = 3, c;
B. for(i = 0, i <= 13, i++) {
C. c = (a * 2) + i;
D. System.out.println(c);
}
B will cause an error.
Allison needs to declare a type for variable i and use semi-colons.
The for statement should be for(int i = 0; i <=13; i++){