// This code contains ERRORS!
int choice, num1, num2;
Scanner keyboard = new Scanner(System.in);
do
{
System.out.print(“Enter a number: ”);
num1 = keyboard.nextInt();
System.out.print(“Enter another number: ”);
num2 = keyboard,nextInt();
System.out.println(“Their sum is ” + (num1 + num2));
System.out.println(“Do you want to do this again? ”);
System.out.print(“1 = yes, 0 = no ”);
choice = keyboard.nextInt();
} while (choice = 1)
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
MyLab Programming with Pearson eText -- Access Code Card -- for Starting Out with Java: From Control Structures through Objects
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects (9th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Mechanics of Materials (10th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (8th Edition)
- Design and write a modular python program for chapter 7 programming exercise #12 from your textbook, with the following modifications: 1. prompt for input of a positive number and call a function to determine if all the numbers from 2 up to and including the input number is a prime or composite number 2. display all the numbers tested with the appropriate label (prime or composite) 3. after completing the task of displaying the numbers the program should ask for a second number input 4. entry of a negative number will end the program Be sure to use clear prompts/labeling for input and output.arrow_forward(-465)10 + (325)10 = ?arrow_forward# hard-coded calls # hard-coded linescouple = NumCouple(4, 7)print(f"The couples minimum is {couple.minimum()}")print(f"The couples maximum is {couple.maximum()}")print(f"The couples product is {couple.product()}")thruple = NumThruple(3, 5, 2)print(f"The thruples minimum is {thruple.minimum()}")print(f"The thruples maximum is {thruple.maximum()}")print(f"The thruples product is {thruple.product()}")arrow_forward
- 'Q1 Write a {pmgram that reads 10 numbers and then finds the latgest number and prints it and finds the smallest number and prints it.arrow_forward#include main() {int=a, b=2, x=0, x=a + b * a + 10/2 * a, printf("value is =%d", x);} What is the value?arrow_forwardmain() { int a = 1, b = 2, c = 3: printf("%d", a + = (a + = 3, 5, a)) } Output of this code will be ? Subject code - rcs501arrow_forward
- Computer Science Part C: Interactive Driver Program Write an interactive driver program that creates a Course object (you can decide the name and roster/waitlist sizes). Then, use a loop to interactively allow the user to add students, drop students, or view the course. Display the result (success/failure) of each add/drop.arrow_forwardComputer Science C# Programming Object Orientation Please use Arrays or ArrayLists where appropriate Implement a menu driven program that has some operations for a food truck. A food truck has multiple food items as well as a menu which contains a selection of the food items which will be sold for that day. A maximum of 10 food items can appear on the menu for any day. For each food item keep a code, description, category, price and quantity in stock (code, description and category are not usually changed). Create a comma delimited text file called "items.txt" for 15 or more food items, indicating the item's description, category, price and quantity in stock. Read all the food items from the text file “Items.txt” Display all the food items available for this food truck. Continuously prompt the user for a food item’s code to be placed on the menu until the menu is full or the user enters -1. Note that only food items which have a positive quantity in stock may be added to…arrow_forward8. Prime Number Generation A positive integer greater than 1 is said to be prime if it has no divisors other than 1 and that asks the user to enter an integer greater than 1, then displays all of the prime numbers itself. A positive integer greater than 1 is composite if it is not prime. Write a program that are less than or equal to the number entered. The program should work as follows: • Once the user has entered a number, the program should populate a vector with all of the integers from 2, up through the value entered. The program should then use the STL's for each function to step through the vector. The for each function should pass each element to a function object that displays the element if it is a prime number. CS CamScannerarrow_forward
- Which of the statement is false and why?i) pCount = &count;ii) *pCount = &count;iii) int* pCount = &count;arrow_forwardPlease provide answer in C#: Slot Machine Simulation A slot machine is a gambling device into which the user inserts money and then pulls a lever (or presses a button). The slot machine then displays a set of random images. If two or more of the images match, the user wins an amount of money that the slot machine dispenses back to the user. Create an application that simulates a slot machine. Figure 8-23 (on page 539 of your book) shows an example of how the form should look. The application should let the user enter into a TextBox the amount of money he or she is inserting into the machine. When the user clicks the Spin button, the application should display three randomly selected symbols. (Slot machines traditionally display fruit symbols. You will find a set of fruit symbols attached to this dropbox for your use - from the Student Sample Programs provided by the book author.) If none of the randomly displayed images match, the program should inform the user that he or she has won…arrow_forward#include <stdio.h>#include <stdlib.h> //declaring variables globally to calculate coinsint cent50 = 0;int cent20 = 0;int cent10 = 0;int cent05 = 0; //calculate change//pass change variable by addressvoid calculateChange(int* change) {//calculate change only if change is positiveif(*change > 0) {if(*change >= 50) {*change -= 50;cent50++;}else if(*change >= 20) {*change -= 20;cent20++;}else if(*change >= 10) {*change -= 10;cent10++;}else if(*change >= 05) {*change -= 05;cent05++;}//call calculateChange recursively calculateChange(change);}} // function to display the cents valuesvoid printChange() { if(cent50)printf("\n50 Cents : %d coins", cent50);if(cent20)printf("\n20 Cents : %d coins", cent20);if(cent10)printf("\n10 Cents : %d coins", cent10);if(cent05)printf("\n05 Cents : %d coins", cent05);//reset all cent variables with 0cent50 = 0;cent20 = 0;cent10 = 0;cent05 = 0; } //take change input from user//change variable passed addressvoid TakeChange(int*…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,