#include using namespace std; void scanPrice (string [], double []); // Do not modify the code double printReceipt (string [0,double []) ; // Do not modify the code int main () { double sum; string item[3] = {"Vegetable","Egg","Meat"}; double price [3];| scanPrice (item,price); sum = printReceipt (item,REİCE); cout<<"Your total expenses is RM "<
Q: Programming language: PHP - A simple program that declares a variable name word, that has any word…
A: Sample output Enter word: Hi JohnFinal output: nhoJ iH14
Q: [In c#] Write a class with name Arrays . This class has an array which should be initialized by…
A: using System; public class GFG { public static void Main() { int[] arr = { 1,…
Q: Fill in the blanks(...)C homework #include #include struct Complex {
A: #include <stdio.h>#include <stdlib.h>struct Complex…
Q: Order check Write a program OrderCheck.java that takes four int command-line arguments w, x, y, and…
A: Logical AND(&&) operator : The logical and operator,&& is used to check if the two…
Q: thon Geography Grades 2 Make a copy of your program for the problem Geography Grades 1 and change…
A: It is defined as an interpreted, object-oriented, high-level programming language with dynamic…
Q: JAVA Programming Problem 5 – CharacterArray Write a program which will store the following string…
A: i wll provide two solutions for this question public class CharacterArray {public static void…
Q: 4.15 LAB: Password modifier Many user-created passwords are simple and easy to guess. Write a…
A: Coded using Python 3.
Q: Grade Book A teacher would like to assign a letter grade to a student, based on student's test…
A: #include<iostream>#include<string.h>#include<stdlib.h>using namespace std;string…
Q: xplain Structures and how this code works: - Imagine you're teaching the material to someone who…
A: Java is one of the languages, which is considerably used in many sectors of Computer. In older…
Q: The phone numbers of the companies are stored in the phones.txt. The area codes are missing in some…
A: Answer :- The functions to readFromFile that reads all the phone numbers from the file phones.txt…
Q: Write a program that will read in N integers from keyboard input into an array. The size of the…
A: Program: //including essential header file #include <iostream> //using standard namespace…
Q: Parameter: An array of strings. Return value: A list of the three strings that occur most frequently…
A: Since no programming language is mentioned, I am using java. Algorithm: Start Initialize array of…
Q: PREPARE 4.3: COMMAND LINE Write a program to convert feet to meters. The conversion from feet to…
A: Write a program to convert feet to meters. The conversion from feet to meters.
Q: Every line of this c program please explain. Thank you Source Code: // include necessary…
A: //include hearder files for using C++ supported library//include cin, cout, etc libraries#include…
Q: Bulgarian solitaire def bulgarian_solitaire(piles, k): You are given a row of piles of pebbles,…
A:
Q: Question Write a program to create an answer sheet to read the student’s answers for a ten (10)…
A: #include<iostream>using namespace std;int main(){ int c=0; string…
Q: Creat a class reversit and Write a function called reversit () that reverses a C-string (an array of…
A: C++ code to reverse the string 1)Create the function reversit() where you are passing the user input…
Q: using this c++ code add these improvements -want to ignore whitespace -allow number #include…
A: The number has been included in the below C program.
Q: Write a java program correctly to read a sentence and display the length of each word, the number of…
A: Use a loop to iterate over the split strings and then we can compare the lengths to find minimum,…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: I give the code in Python (because no language is mentioned) along with output and code screenshot.…
Q: Fill in the blanks(...)C homework #include #include struct Complex { ... }; …set_real(…){ … }…
A: Fill in the blanks(...)C homework #include <stdio.h>#include <stdlib.h>struct Complex…
Q: IN PYTHON PLEASE!!! (Find the index of the smallest element) Write a function that returns the…
A: Given: IN PYTHON PLEASE!!! (Find the index of the smallest element) Write a function that returns…
Q: ain.cpp #include #include #include using namespace std; // TODO: Write method to create and…
A: Step 1: Prompt and accept the string of names separated by spaces and ending with -1. Step 2:…
Q: File CountLetters.java contains a program that reads a word from the user and prints the number of…
A: The given code generates an ArrayIndexOutOfBoundsException when more than one word is entered as an…
Q: ingVar() i max_length(20) value - new char(max_length+1]; value(0) - '\0': Default constructor $ize…
A: //source code in C++ #include<iostream> #include<memory> #include<string>…
Q: C++ code output must be: Enter series of parentheses: Not Balance! What is the problem of this…
A: I have given errorless code with output below.
Q: 5.13 LAB: Password modifier Many user-created passwords are simple and easy to guess. Write a…
A: Algorithm: 1. Input word 2. Run through for loop. 3. Print the output
Q: Define a class called StringFormatter. The purpose of an object of this class is to store a string…
A: The C++ program is given by #include <iostream> #include<string> using namespace…
Q: a. Write a C++ statement that declares secretList to be a vector object to store integers. (Do not…
A: a) vector<int> secretList;
Q: In C++ struct myGrades { string class; char grade; }; Declare myGrades as an array that…
A: The problem is based on the basics of structures in C++ programming language. NOTE: The name of a…
Q: 1. Prompt the user to enter a vector of maximum 10 digits. Note: the vector entered can contain…
A: C code :- #include<stdio.h>int fun(int[],int,int);int main() { int n,arr[30],i;…
Q: For this code, just explain the void pop function, with each and every line. And please provide…
A: POP function:- Basically POP function created to remove the top elements l from the stack.
Q: Write a C++ program to create a class template using an array. Perform operations like sorting,…
A: Solution:-- 1)The given question has required for the solution which is to be provided in the C++…
Q: In c++. Please need rescurive arrays such as in picture from level 0 to level 1 to level 2. split…
A: ANSWER: Program 1: Output:
Q: (Game: pick four cards) Write a program which creates a deck of cards of 52 and pick any four cards…
A: As Language is not defined I'm doing it in Java Language
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: Algorithm - Take input from user. Now use the below logic - let isTooTall = arr.length > 3;…
Q: . Given a string of at least 3 characters as input, if the length of the string is odd return the…
A: The code has given below
Q: In Java list all the values of the array after the function is called A. static void…
A: In Java list all the values of the array after the function is called elements.
Q: Q.No.1. (Marks: 30) Write a complete C# console application in which you will have to store data of…
A: using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace…
Q: use c++ Write a class Calculator using templates. The template class shall allow you to perform…
A: #include <iostream>using namespace std; template <class T>class SimpleCalc{private: T…
Q: c++complete and change #include using namespace std; int sumbyrow(int* m, int ncol, int row) {…
A: Note : I am considering that you are facing some logical error in this code which is not…
Q: #include void main () { int a=5,b=10,c=1; if (a && b>c){ printf("cquestionbank") ; else{ break; } }
A: The keyword break is not a part of the if-else statement's syntactical form. As a consequence, the…
Q: Assign Barbecue's data member numberOfCalories with a value read from input. Then, assign Ham and…
A: 1. input 2 integers a and b 2. assign availablePizzas.at(0).numberOfCalories to a 3. assign…
Q: Art.java must take one (1) integer command-line argument n that controls the depth of recursion.…
A: import java.awt.*;import javax.swing.*; public class DrawLines extends JPanel { static int i = 0;…
Q: 5.19 (Rectangle of Hashes) Write a function that displays a solid rectangle of hashes whose length…
A: Please find the answer below :
Q: Write an application which defines String=”hello world”, convert it into character array through…
A: CODE : public class StringToCharArray{ public static void main(String args[]){ String s="hello…
Q: pls debug this pseudocode
A: Debug required in the following part of the code: Since, there are 4 years (1 to 4) in a school, so…
Q: Absolute Value Template Write a function template that accepts an argument and returns its absolute…
A: Answer : Step : 1 Program Plan: • Definition of the function template maximum is as follows:…
Q: Complete the code for the following function so it matches its documentation: def…
A: def doubleList(numberList): #defining the function with list as a Parameter for num in…
Q: Unfair hurdles are hurdles which are either too high, or way too close together. Create a function…
A: Since the programming language is not mentioned , I have done the code using JavaScript.
Step by step
Solved in 3 steps with 2 images
- Topic: pointers, dynamic array and command line arguments Write a complete C++ program named “showHelp” that accepts command line arguments. It checks whether there is a command line argument of “/help” or“/?” or “-help” followed by a topic number. It will print out “yes, topic number(<number>) if there is one. Otherwise, it prints out “no, topic number(N/A) For example, if you run this program with correct arguments as follows, it willprint out yes and its associated topic number respectivelyshowHelp /? 101showHelp /debug /help 102showHelp /print /help 103 /verboseshowHelp -verbose -debug -help And if you run the program with invalid arguments, it will print no, in all casesshowHelp -helpshowHelp 101 /?showHelp 101 102 /help /verboseshowHelp /? /help -helpNote: command line arguments are simply an array of pointers to C-string. example code: #include <iostream> using namespace std; int main(int argc, char** argv){...}Creat a class reversit and Write a function called reversit () that reverses a C-string (an array of char). Use a forloop that swaps the first and last characters, then the second and next-to-last characters, and so on. The string should be passed to reversit () as an argument. Write a program to exercise reversit (). The program should get a string from the user, call reversit (), and print out the result.by using c++In c++ The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown in Figure. The Lo ShuMagic Square has the following properties:• The grid contains the numbers 1 through 9 exactly• The sum of each row, each column, and each diagonal all add up to the same number.In a program you can simulate a magic square using a two-dimensional array. Write a functionthat accepts a two-dimensional array as an argument, and determines whether the array is a LoShu Magic Square. Test the function in a program.
- c++complete and change #include <iostream>using namespace std; int sumbyrow(int* m, int ncol, int row){int total = 0;for (int i = 0 i < ncol; i++) {total += m[row * ncol + i];}return total; } int sumBCol(int* m, int nrow, int ncol, int col){int total = 0;for (int j = 0; < j nrow; j++) {total += m[j * ncol + col]; }return total;}int sumBYLeftDiag(int* m, int ncol){int total = 0;for (int i = 0, j = ncol - 1; i < ncol && j >= 0; i++, j--) {total += m[i * ncol + j];}return total;}bool hasDuplicates(int* m, int row) {int flatArray[row * row];int k = 0for (int i = 0; i < row; i++) {for (int j = 0; j < row; j++) {flatArray[k++] = m[i * row + j]; }}for (int i = 0; i < (row * row); i++) {for (int j = i + 1; j < (row * row); j++) {if (flatArray[i] == flatArray[j])return true; }}return flase;} bool isMagicMatrix(int* m, int nrow, int ncol) { if (hasDuplicate(m, nrow), int ncol{return false; }if (sumByleftDiag(m, nrow) != sumByRightDiag(m, nrow)) {return…(Initialize array) Write a function called initializeArray that receives an array, its size, and two integers and initializes the array with random values between the first integer and the second integer. Write another function called printArray that receives an array and its size and prints the array elements in a column. Write a test program that declares and initializes an array of size 20 with random values between 0 and 10 inclusive, and then prints the array using the above functions Write a C++ program that declares and initializes an integer array of size 100 with random integers between 1 and 10 inclusive using initializeArray (from question 1) and counts the occurrence of each number in the array and graphs the information in the form of a bar chart or histogram—each number is printed, then a bar consisting of that many asterisks is printed beside the number. Here is a sample run of the program: Number Value Histogram 1…(Initialize array) Write a function called initializeArray that receives an array, its size, and two integers and initializes the array with random values between the first integer and the second integer. Write another function called printArray that receives an array and its size and prints the array elements in a column. Write a test program that declares and initializes an array of size 20 with random values between 0 and 10 inclusive, and then prints the array using the above functions Write a C++ program that declares and initializes an integer array of size 100 with random integers between 1 and 10 using initializeArray (from question 1) and counts the occurrence of each number in the array and prints the occurrences. Note: Print time or times correctly. Hint: Declare another array called count that stores the number of each value as you count the numbers of the original array. Use printArray (from question 1) to print the values of count. Here is a sample run of the program: 1…
- Every line of this c program please explain. Thank you Source Code: // include necessary header files# include<stdio.h># include<time.h># include<stdlib.h> int main(){ // Use current time as seed srand(time(0)); // declare variables int arr[5][5] = {0}, user_num[5] = {0}, k = 1, i, j; int num[75] = {0}, n, flag, count, winner = 0; // initialize num array for(i = 0; i < 75; i++) num[i] = k++; // initialize the array cell with random numbers for(i = 0; i < 5; i++){ for(j = 0; j < 5; j++){ while(1){ // generate random numbers n = rand() % 75; if(num[n] != 0){ arr[i][j] = n + 1; num[n] = 0; break;…Parallel Array in Java Summary In this lab, you use what you have learned about parallel arrays to complete a partially completed Java program. The program should either print the name and price for a coffee add-in from the Jumpin’ Jive coffee shop or it should print the message: "Sorry, we do not carry that.". Read the problem description carefully before you begin. The data file provided for this lab includes the necessary variable declarations and input statements. You need to write the part of the program that searches for the name of the coffee add-in(s) and either prints the name and price of the add-in or prints the error message if the add-in is not found. Instructions Study the prewritten code to make sure you understand it. Write the code that searches the array for the name of the add-in ordered by the customer. Write the code that prints the name and price of the add-in or the error message, and also write the code that prints the total order cost. Execute the program…Bulgarian solitaire def bulgarian_solitaire(piles, k): You are given a row of piles of pebbles, all identical, and a positive integer k so that the total number of pebbles in these piles equals k*(k+1)//2, the arithmetic sum formula that equals the sum of positive integers from 1 to k. Almost as if intended as a metaphor for the bleak daily life behind the Iron Curtain, all pebbles are identical and you don't have any choice in your moves. Each move picks up one pebble from each pile (even if doing so makes that pile vanish), and creates a new pile from the resulting handful. For example, starting with[7, 4, 2, 1, 1], the first move turns this into [6, 3, 1, 5]. The next move turns that into [5, 2, 4, 4], which then turns into the five-pile configuration [4, 1, 3, 3, 4], and so on. This function should count how many moves are needed to convert the given initial piles into the goal state where each number from 1 to k appears as the size of exactly one pile, and return that count. These…
- Write C++ application with several functions that deal with a two-dimensional array of positive integers: The number of rows and number of columns of the array should be 20. Fill the array with random numbers between 1 and 1000. Display a table that contains the array values, numbers (elements of the array) should be aligned. Display the indexes, for example (rowIndex,columnIndex), where the prime numbers are stored. Display a table of the same size of the input array that contains the array values of prime numbers that you found. Do not show the composite numbers in the array. That is, you should leave out blanks for the composite numbers or put zeros in that position.#include <string>#include <iostream>#include <vector>class Snack{public:Snack(std::string, float, bool);int set_price(float);void set_expired(bool);void set_name(std::string);std::string name() const{return name_;}float price() const{return price_;}bool expired() const{return expr_;}int how_many_for_ten();private:std::string name_;float price_;bool expr_;};void SortByPrice(std::vector<Snack>&,bool); Task: Implement a function working with Snack objects that are stored using a vector. It has the following signature: void SortByPrice(std::vector<Snack>& list_ref, bool asc). This function should sort the vector list_ref based on the price_ of the Snacks. The sorting should be done in the following order: Ascending if asc is true Descending if asc is false. In both cases if variables have the same value for price_, the sorting should be done based on the name_ in ascending order.5.20 LAB: Two smallest numbers (JAVA) Write a program in java that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and fewer than 20 integers. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 and 3 To achieve the above, first read the integers into an array. Hint: Make sure to initialize the second smallest and smallest integers properly. Code starts here: import java.util.Scanner; public class LabProgram { public static void main(String[] args) { /* Type your code here. */ }}