In the previous verse, we asked the user to input 5 inventory items. In this verse, we need to ensure the values they entered are valid values for the two fields of each inventory item. Continue to ask the user to input the inventory id # (integer) and the price (float) for 5 inventory items. After the user enters each value, ensure the value entered is greater than 0. If the value is less than or equal to 0, then write a descriptive error message and end the program. To end a program, call the exit function and pass 0 as an argument.
In: Computer Science
JAVA programing language:
What is printed when the following code is executed?
int columns;
int rows;
for(rows = 1; rows < 2; ++rows) {
for(columns = 1; columns < 3; ++columns) {
System.out.print("x");
}
System.out.println():
}
select one:
A)
xx
B)
xxx
xxx
C)
x
x
D)
xx
xx
xx
In: Computer Science
/* Assignment : Complete this javascript file according instructions in comments. */ // 1) Create a for loop that loops through its code block 10 times // In the first statement, set the variable i equal to zero // In the second statement, tell the loop to execute while i is less than ten // In the third statement, increment i by one each time the loop executes // In the code block of the loop, print the variable i to the console // 2) Create an array named foods and put your 5 favorite foods // in the array as items. // 5 fav foods = sushi, ramen, korean bbq, pizza, wings // Create a for / in loop that will loop through the items in the foods array // Print a favorite food item to the console each time the loop executes // When finished, you should have printed each favorite food item to the console // 3) Create a variable x and set it equal to 50. // Create a while loop that executes while x is greater than zero. // Print the value of x to the console every time the loop executes. // Decrement the value of x by one every time the loop executes. // Your loop should count backwards from 50 to 1 and print each number in the // console. // 4) Create a variable named myNum and set it equal to 10. // Create a while loop that executes while myNum is less than 5. // In the loop, print the value of myNum to the console. // Below that loop, create a do / while loop. // Set the while condition the same as first while loop. // Print the value of myNum to the console in the loop. // Comment below your loops to explain the outcome. /* multi-line comment */ // 5) Create a variable named x and set it equal to zero. // Create a while loop that executes while x is less than ten. // In the code block of the loop, set x equal to a random number between // one and ten using the previous random number formula we learned with // the Math object. // After assigning x the random number, print the value of x to the console. // The loop should continue to execute until the value of x equals 10.
In: Computer Science
c++ Create a program that creates a sorted list from a data file. The program will prompt the user for the name of the data file. Create a class object called group that contains a First Name, Last Name, and Age. Your main() function should declare an array of up to 20 group objects, and load each line from the input file into an object in the array. The group class should have the following private data elements: first name ,last name age The group class should have the following functions: Constructor(s) Destructor - optional Get - read first name, last name, and age from an input stream Put - write last name, first name, and age to an output stream The group class should have the following operators: > < == compare the group to another group, using Last name, First name, then age, and return a bool Your program should do the following: Prompt the user for the name of the file Open the file Read the data into the array of group objects (maximum size 20) Close the file Sort the array Display the array ============== text file Ann ember 70 jacob Mark 68 David smith 45 Frank lee 37 John doe 30 Kathleen honor 34 bob ember 42 bob ember 13 Richard start 47 Susan hox 36 Expert Answer
In: Computer Science
THE FOLLOWING MUST BE CODED IN C THE FOLLOWING MUST BE CODED IN C
THE FOLLOWING MUST BE CODED IN C THE FOLLOWING MUST BE CODED IN C
Write a program that demonstrates handling pointers. Create two integer variables m and n, and two pointers, pm pointing to m, and pn pointing to n.
Produce the following output:
Address of m: 0x7ffcc3ad291c
Value of m: 29
Address of n: 0x7ffcc3ad291d
Value of n: 34
Now pm is pointed to m by assigning the address of m to pm
Address of pointer pm: 0x7ffcc3ad2100
Value of pointer pm: 0x7ffcc3ad291c
Content of pointer pm (dereferencing): 29
Now pn is pointed to n by assigning the address of n to pn
Address of pointer pn: 0x7ffcc3ad2101
Value of pointer pn: 0x7ffcc3ad291d
Content of pointer pn (dereferencing): 34
Thank you!
In: Computer Science
Prompt the user to input their lucky number. Upon getting the users input, validate that the input is a valid number using Int32.TryParse (more info can be found at https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/how-to-convert-a-string-to-a-number (Links to an external site.)). If the input is not a valid number, output a message to the user stating that you are sorry but you are unable to run the FizzBuzz process due to the input not being a valid number. If the input is valid, you are clear to start the FizzBuzz process. If the input is divisible by 3, then output {number} Fizz. If the input is divisible by 5, then output {number} Buzz. If the input is divisible by 3 AND 5, output {number} FizzBuzz. If it is not divisible by either 3 or 5, simply just output the number.
In: Computer Science
In: Computer Science
Convert the following to Octal, hexadecimal and binary (long method(multiply and Divide by methods))
a.1364.367(10)
b.1568.246(10)
c.846.578(10)
d.245.86(10)
e.2647.95(10)
In: Computer Science
////Fixme(1) add a statement to import ArrayList class
public class ListManipulation {
public static void main(String[] args) {
//Fixme(2) create an ArrayList of integers and name the ArrayList
list.
//Fixme(3) add the following numbers to the list: 10, 15, 7, -5,
73, -11, 100, 20, 5, -1
displayList(list);
System.out.println();
displayListBackwards(list);
}
public static void displayList(ArrayList<Integer> list)
{
for(Integer i: list)
System.out.print(i + " ");
}
//Fixme(4) define a method displayListBackwards, which takes an
ArrayList as a parameter and returns nothing.
//The method displays each element in the list in the reverse
order, and adds a space after each element.
//Fixme(5) define a method maxElement, which takes an ArrayList as
a parameter and returns the maximum element in the list.
//Fixme(6) define a method searchElement, which takes two
parameters.
//The first parameter is an ArrayList and the second is an int type
value.
//The method searches for value in the list.
//If the value is found in the list, the method returns its index,
otherwise, it returns -1.
//Fixme(7) define a method eventCount, which takes an ArrayList as
a parameter and returns the number of even element in the
list.
}
In: Computer Science
In: Computer Science
In: Computer Science
give an arbitrary list of integers, how many are 3? (in scheme)
In: Computer Science
Write a program in Python jupyter notebook for
following:
Part1:
Course grade calculation: Course grades for CIS 1100 are calculated
based on two assignments, a midterm exam, and a final exam. Here
are the weights of these.
Assignments 25%
Midterm exam 35%
Final exam 40%
Ask the user for the scores they received for the two assignments, midterm exam, and the final exam. Then calculate and display their total weighted score they received for the course.
Based on the weighted score, calculate and display the letter grade. Here are the grading guidelines:
Score >=90: A
Score >=80: B
Score >=70: C
Score <70: F
Part 2:
The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here:
When you mix red and blue, you get purple.
When you mix red and yellow, you get orange.
When you mix blue and yellow, you get green.
Design a program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results.
In: Computer Science
Write a function
void reverse(char * s)
that reverses the string passed as an argument. Your code should use pointer arithmetic (it may increment and decrement pointers, but it may not use array indexing).
Here is a piece of code that shows the behavior of reverse:
char buf[100];
strcpy(buf, “hello”);
reverse(buf);
printf(“%s\n”, buf); // output should be olleh
In: Computer Science
Calculate A+B, A-B, AxB, and A/B for each of the following pairs of binary numbers. (Assume the first number in each pair = A and the second number =B). Append all numbers to 8 bits. Subtraction is not2’s complement.
a.1010101, 011010
b.101101, 10101
c.11001, 1100
d.1010101, 1110
In: Computer Science