Answer:
Explanation:
The following is written in Java. It uses File input, to get the file and read every line in the file. It adds all the lines into a variable called fullString. Then it uses regex to split the string into separate words. Finally, it maps the words into an array that counts all the words and how many times they appear. A test case has been created and the output can be seen in the attached image below. Due to technical difficulties I have added the code as a txt file below.
If the signal is going through a 2 MHz Bandwidth Channel, what will be the maximum bit rate that can be achieved in this channel? What will be the appropriate signal level?
Answer:
caca
Explanation:
Can we update App Store in any apple device. (because my device is kinda old and if want to download the recent apps it aint showing them). So is it possible to update???
Please help
Answer:
For me yes i guess you can update an app store in any deviceI'm not sure×_× mello ×_×Briefly explain what an array is. As part of your answer make use of a labelled example to show the declaration and components of an array
Answer:
Explanation:
In programming an array is simply a grouping of various pieces of data. Various data elements are grouped together into a single set and saved into a variable. This variable can be called which would return the entire set which includes all of the elements. The variable can also be used to access individual elements within the set. In Java an example would be the following...
int[] myArray = {33, 64, 73, 11, 13};
In Java, int[] indicates that the variable will hold an array of integers. myArray is the name of the variable which can be called to access the array elements. The elements themselves (various pieces of data) are located within the brackets {}
LAB: Acronyms
An acronym is a word formed from the initial letters of words in a set phrase. Write a program whose input is a phrase and whose output is an acronym of the input. If a word begins with a lower case letter, don't include that letter in the acronym. Assume there will be at least one upper case letter in the input.
If the input is
Institute of Electrical and Electronics Engineers
the output should be
IEEE
Answer:
LAB means laboratory
IEEE means institute of electrical and electronic engineer
For the following 4-bit operation, assuming these register are ONLY 4-bits in size, which status flags are on after performing the following operation? Assume 2's complement representation. 1010+0110
a) с
b) Z
c) N
Answer:
All flags are On ( c, z , N )
Explanation:
Given data:
4-bit operation
Assuming 2's complement representation
Determine status flags that are on after performing 1010+0110
1 1
1 0 1 0
0 1 1 0
1 0 0 0 0
we will carry bit = 1 over
hence C = 1
given that: carry in = carry out there will be zero ( 0 ) overflow
hence V = 0
also Z = 1
But the most significant bit is N = 1
This means that the surface area is composed of the base area (i.e., the area of bottom square) plus the side area (i.e., the sum of the areas of all four triangles). You are given the following incomplete code to calculate and print out the total surface area of a square pyramid: linclude > h: base azea- calcBasekrea (a) : cout << "Base auxface area of the squaze pyzamid is" << base area << "square feet."< endi: // add your funetion call to calculate the side ares and assign // the zesult to side area, and then print the result //hdd your function call to print the total surface area return 0F float calcBaseArea (float a) return pou (a, 2) /I add your function definicion for calcSideärea here // add your function definition tor prntSurfârea here This code prompts for, and reads in the side length of the base (a) and height of a square pyramid (h) in feet, and then calculates the surface area. The function prototype (i.e. function declaration), function definition, and function call to calculate and print the base area has already been completed for you. In the above program, a and h are declared in the main function and are local to main. Since a is a local variable, notice how the length a must be passed to calcBaseArea to make this calculation. One of your tasks is to add a new function called calesidearea that computes and returns the side area of the square pyramid. Given that the formula uses both the length a and height h of the square pyramid, you must pass these two local variables to this function. You will assign the returned value of this function to side area and then print the value to the terminal. Refer to what was done for calcBaseArea when adding your code. Your other task is to add a new function called prntsprfArea that accepts the base area and side area values (i.e, these are the parameters) and prints out the total surface area of the square pyramid inside this function. Since this function does not return a value to the calling function, the return type of this function should be void Now, modify the above program, referring to the comments included in the code. Complete the requested changes, and then save the file as Lab7A. opp, making sure it compiles and works as expected. Note that you will submit this file to Canvas
Answer:-
CODE:
#include <iostream>
#include<cmath>
using namespace std;
float calcBaseArea(float a);
float calcSideArea(float s,float l);
void prntSprfArea(float base_area,float side_area);
int main()
{
float h;
float a;
float base_area
float side_area;
cout<<"Enter the side length of the base of the square pyramid in feet : ";
cin>>a;
cout<<"Enter the height of the square pyramid in feet : ";
cin>>h;
base_area=calcBaseArea(a);
side_area=calcSideArea(a,h);
cout<<"Base surface area of the square pyramid is "<<base_area<<" square feet. "<<endl;
cout<<"Side area of the square pyramid is "<<side_area<<" square feet."<<endl;
prntSprfArea(base_area,side_area);
return 0;
}
float calcBaseArea(float a)
{
return pow(a,2);
}
float calcSideArea(float s,float l)
{
float area=(s*l)/2;
return 4*area;
}
void prntSprfArea(float base_area,float side_area)
{
cout<<"Total surface area of the pyramid is "<<base_area+side_area<<" square feet.";
OUTPUT:
Write a RainFall class that stores the total rainfall for each of 12 months into an array of doubles. The program should have methods that return the following:
the total rainfall for the year
the average monthly rainfall
the month with the most rain
the month with the least rain
Demonstrate the class in a complete program.
Input Validation: Do not accept negative numbers for monthly rainfall figures.
import java.io.*;
import java.util.*;
public class Rainfall
{
Scanner in = new Scanner(System.in);
private int month = 12;
private double total = 0;
private double average;
private double standard_deviation;
private double largest;
private double smallest;
private double months[];
public Rainfall()
{
months = new double[12];
}
public void setMonths()
{
for(int n=1; n <= month; n++)
{
System.out.println("Enter the rainfall (in inches) for month #" + n + ":" );
months[n-1] = in.nextInt();
}
}
public double getTotal()
{
total = 0;
for(int i = 0; i < 12; i++)
{
total = total + months[i];
}
System.out.println("The total rainfall for the year is" + total);
return total;
}
public double getAverage()
{
average = total/12;
System.out.println("The average monthly rainfall is" + average);
return average;
}
public double getLargest()
{
double largest = 0;
int largeind = 0;
for(int i = 0; i < 12; i++)
{
if (months[i] > largest)
{
largest = months[i];
largeind = i;
}
}
System.out.println("The largest amout of rainfall was" + largest +
"inches in month" + (largeind + 1));
return largest;
}
public double getSmallest()
{
double smallest = Double.MAX_VALUE;
int smallind = 0;
for(int n = 0; n < month; n++)
{
if (months[n] < smallest)
{
smallest = months[n];
smallind = n;
}
}
System.out.println("The smallest amout of rainfall was" + smallest +
"inches in month " + (smallind + 1));
return smallest;
}
public static void main(String[] args)
{
Rainfall r = new Rainfall();
r.setMonths();
System.out.println("Total" + r.getTotal());
System.out.println("Smallest" + r.getSmallest());
System.out.println("Largest" + r.getLargest());
System.out.println("Average" + r.getAverage());
}
}
Answer:
Explanation:
The code provided worked for the most part, it had some gramatical errors in when printing out the information as well as repeated values. I fixed and reorganized the printed information so that it is well formatted. The only thing that was missing from the code was the input validation to make sure that no negative values were passed. I added this within the getMonths() method so that it repeats the question until the user inputs a valid value. The program was tested and the output can be seen in the attached image below.
import java.io.*;
import java.util.*;
class Rainfall
{
Scanner in = new Scanner(System.in);
private int month = 12;
private double total = 0;
private double average;
private double standard_deviation;
private double largest;
private double smallest;
private double months[];
public Rainfall()
{
months = new double[12];
}
public void setMonths()
{
for(int n=1; n <= month; n++)
{
int answer = 0;
while (true) {
System.out.println("Enter the rainfall (in inches) for month #" + n + ":" );
answer = in.nextInt();
if (answer > 0) {
months[n-1] = answer;
break;
}
}
}
}
public void getTotal()
{
total = 0;
for(int i = 0; i < 12; i++)
{
total = total + months[i];
}
System.out.println("The total rainfall for the year is " + total);
}
public void getAverage()
{
average = total/12;
System.out.println("The average monthly rainfall is " + average);
}
public void getLargest()
{
double largest = 0;
int largeind = 0;
for(int i = 0; i < 12; i++)
{
if (months[i] > largest)
{
largest = months[i];
largeind = i;
}
}
System.out.println("The largest amount of rainfall was " + largest +
" inches in month " + (largeind + 1));
}
public void getSmallest()
{
double smallest = Double.MAX_VALUE;
int smallind = 0;
for(int n = 0; n < month; n++)
{
if (months[n] < smallest)
{
smallest = months[n];
smallind = n;
}
}
System.out.println("The smallest amount of rainfall was " + smallest +
" inches in month " + (smallind + 1));
}
public static void main(String[] args)
{
Rainfall r = new Rainfall();
r.setMonths();
r.getTotal();
r.getSmallest();
r.getLargest();
r.getAverage();
}
}
True or false, an implicitly unwrapped optional variable must have an exclamation mark affixed after it every time it is used. 答案选项组
Answer:
False.
Explanation:
Implicit unwrapped optional variables are those which are at option and they might be nil. It is not necessary that all implicit unwrapped optional variables should have an exclamation mark. Swift may eliminate the need for unwrapping.
You are given a sequence of n songs where the ith song is l minutes long. You want to place all of the songs on an ordered series of CDs (e.g. CD 1, CD 2, CD 3,... ,CD k) where each CD can hold m minutes. Furthermore, (1) The songs must be recorded in the given order, song 1, song 2,..., song n. (2) All songs must be included. (3) No song may be split across CDs. Your goal is to determine how to place them on the CDs as to minimize the number of CDs needed. Give the most efficient algorithm you can to find an optimal solution for this problem, prove the algorithm is correct and analyze the time complexity
Answer:
This can be done by a greedy solution. The algorithm does the following:
Put song 1 on CD1.
For song 1, if there's space left on the present CD, then put the song on the present CD. If not, use a replacement CD.
If there are not any CDs left, output "no solution".
Explanation:
The main thing is prove the correctness, do that by the "greedy stays ahead argument". For the primary song, the greedy solution is perfect trivially.
Now, let the optimal solution match the greedy solution upto song i. Then, if the present CD has space and optimal solution puts song (i+1) on an equivalent CD, then the greedy and optimal match, hence greedy is not any worse than the optimal.Else, optimal puts song (i + 1) on subsequent CD. Consider an answer during which only song (i + 1) is moved to the present CD and zip else is modified. Clearly this is often another valid solution and no worse than the optimal, hence greedy is not any worse than the optimal solution during this case either. This proves the correctness of the algorithm. As for every song, there are constantly many operations to try to do, the complexity is O(n).
Write an expression that evaluates to True if the string associated with s1 is greater than the string associated with s2
Answer:
Explanation:
The following code is written in Python. It is a function that takes two string parameters and compares the lengths of both strings. If the string in variable s1 is greater then the function returns True, otherwise the function returns False. A test case has been provided and the output can be seen in the attached image below.
def compareStrings(s1, s2):
if len(s1) > len(s2):
return True
else:
return False
print(compareStrings("Brainly", "Competition"))
Complete the AscendingAndDescending application so that it asks a user to enter three integers. Display them in ascending and descending order.An example of the program is shown below:Enter an integer... 1 And another... 2 And just one more... 3 Ascending: 1 2 3 Descending: 3 2 1GradingWrite your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade.Once you are happy with your results, click the Submit button to record your score.
Answer:
Following are the solution to the given question:
import java.util.Scanner;//import package
public class AscendingAndDescending//defining a class AscendingAndDescending
{
public static void main(String[] args) //main method
{
int n1,n2,n3,min,max,m;
Scanner in = new Scanner(System.in);//creating Scanner class object
System.out.print("Enter an integer: ");//print message
n1 = in.nextInt();//input value
System.out.print("And another: ");//print message
n2 = in.nextInt();//input value
System.out.print("And just one more: ");//print message
n3 = in.nextInt();//input value
min = n1; //use min variable that holds value
max = n1; //use mix variable that holds value
if (n2 > max) max = n2;//use if to compare value and hols value in max variable
if (n3 > max) max = n3;//use if to compare value and hols value in max variable
if (n2 < min) min = n2;//use if to compare value and hols value in min variable
if (n3 < min) min = n3;//use if to compare value and hols value in min variable
m = (n1 + n2 + n3) - (min + max);//defining m variable that arrange value
System.out.println("Ascending: " + min + " " + m + " " + max);//print Ascending order value
System.out.println("Descending: " + max + " " + m + " " + min);//print Descending order value
}
}
Output:
Enter an integer: 8
And another: 9
And just one more: 7
Ascending: 7 8 9
Descending: 9 8 7
Explanation:
In this program inside the main method three integer variable "n1,n2, and n3" is declared that inputs value from the user end and also defines three variable "min, max, and m" that uses the conditional statement that checks inputs value and assigns value according to the ascending and descending order and prints its values.
In this era of technology, everyone uses emails for mail and messages. Assume you have also used the
mailboxes for conversation. Model the object classes that might be used in Email system implementation
to represent a mailbox and an email message.
Assume You are working as a software engineer and now you have been asked to deliver a presentation to
a manager to justify the hiring of a system architect for a new project. Write a list of bullet points setting
out the key points in your presentation in which you explain the importance of software architecture
Answer:
A class may be a structured diagram that describes the structure of the system.
It consists of sophistication name, attributes, methods, and responsibilities.
A mailbox and an email message have certain attributes like, compose, reply, draft, inbox, etc.
Software architecture affects:
Performance, Robustness, Distributability, Maintainability.
Explanation:
See attachment for the Model object classes which may be utilized in the system implementation to represent a mailbox and an email message.
Advantages:
Large-scale reuse Software architecture is vital because it affects the performance, robustness, distributability, and maintainability of a system.
Individual components implement the functional system requirements, but the dominant influence on the non-functional system characteristics is that the system's architecture.
Three advantages of System architecture:
• Stakeholder communication: The architecture may be a high-level presentation of the system which will be used as attention for discussion by a variety of various stakeholders.
• System analysis: making the system architecture explicit at an early stage within the system development requires some analysis.
• Large-scale reuse:
An architectural model may be a compact, manageable description of how a system is organized and the way the components interoperate.
The system architecture is usually an equivalent for systems with similar requirements then can support large-scale software reuse..
How can COUNTIF, COUNTIFS, COUNT, COUNTA, and COUNTBLANK functions aide a company to support its mission or goals
Answer:
Following are the responses to these questions:
Explanation:
It employs keywords to autonomously do work tasks. Users can type numbers directly into the formulas or use the following formulae, so any data the cells referenced provide would be used in the form.
For instance, this leadership involves accounting, and Excel is concerned with organizing and organizing numerical data. In this Equation, I can discover all its information in the data. This idea is simple me count the number many cells containing a number, and also the number of integers. It counts integers in any sorted number as well. As both financial analysts, it is helpful for the analysis of the data if we want to maintain the same number of neurons.
14. For the declaration, int a[4] = {1, 2, 3};, which one is right in the following description-
(
A. The meaning of &a[1] and a[1] are same B. The value of a[1] is 1-
C. The value of a[2] is 3
D. The size of a is 12 bytes
Answer:
A.
thanks later baby HAHAHAHAHAA
Jane is a full-time student on a somewhat limited budget, taking online classes, and she loves to play the latest video games. She needs to update her computer and wonders what to purchase. Which of the following might you suggest?
a. A workstation with a 3.9 GHz quad-core processor, 16 gigabytes of RAM, and a 24" monitor.
b. A laptop system with a 3.2 GHz processor. 6 gigabytes of RAM, and a 17" monitor.
c. A desktop system with a 1.9 GHz processor, 1 gigabyte of RAM, and a 13" monitor
d. A handheld PC (with no smartphone functionality)
Answer:
a. A workstation with a 3.9 GHz quad-core processor, 16 gigabytes of RAM, and a 24" monitor.
Explanation:
From the description, Jane needs to be able to multitask and run various programs at the same time in order to be efficient. Also since she wants to play the latest video games she will need high end hardware. Therefore, from the available options the best one would be a workstation with a 3.9 GHz quad-core processor, 16 gigabytes of RAM, and a 24" monitor. This has a very fast cpu with 4 cores to process various threads at the same time. It also has 16GB of memory to be able to multitask without problems and a 24" monitor. From the available options this is the best choice.
You know different types of networks. If two computing station high speed network link for proper operation which of the following network type should be considered as a first priority?
MAN
WAN
WLAN
LAN
All of these
Answer:
All of these.
PLZ MARK ME BRAINLIEST.
What order? (function templates) Define a generic function called CheckOrder() that checks if four items are in ascending, neither, or descending order. The function should return -1 if the items are in ascending order, 0 if the items are unordered, and 1 if the items are in descending order. The program reads four items from input and outputs if the items are ordered. The items can be different types, including integers, strings, characters, or doubles. Ex. If the input is:
Answer:
Explanation:
The following code was written in Java and creates the generic class to allow you to compare any type of data structure. Three different test cases were used using both integers and strings. The first is an ascending list of integers, the second is a descending list of integers, and the third is an unordered list of strings. The output can be seen in the attached image below.
import java.util.Scanner;
class Brainly {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Order: " + checkOrder(10, 22, 51, 53));
System.out.println("Order: " + checkOrder(55, 44, 33, 22));
System.out.println("Order: " + checkOrder("John", " Gabriel", "Daniela", "Zendaya"));
}
public static <E extends Comparable<E>> int checkOrder(E var1, E var2, E var3, E var4) {
E prevVar = var1;
if (var2.compareTo(prevVar) > 0) {
prevVar = var2;
} else {
if (var3.compareTo(prevVar) < 0) {
prevVar = var3;
} else {
return 0;
}
if (var4.compareTo(prevVar) < 0) {
return 1;
} else {
return 0;
}
}
if (var3.compareTo(prevVar) > 0) {
prevVar = var3;
}
if (var4.compareTo(prevVar) > 0) {
return -1;
}
return 0;
}
}
Miguel has decided to use cloud storage. He needs to refer to one of the files he has stored there, but his internet service has been interrupted by a power failure in his area. Which aspect of his resource (the data he stored in the cloud) has been compromised
Answer: Availability
Explanation:
Which of the following are issues in data integration? (which would actually cause conflicts) Question 4 options: Two different databases may have different column names for the same actual information (e.g. customer ID vs customer-id). Databases on related subjects that you want to integrate may have different numbers of columns or rows. An attribute named 'weight' may be in different units in different databases. There may be discrepancies between entries in two different databases for the same actual real-life entity (e.g. for an employee).
Answer:
The observed issues in data integration include the following from the listed options:
Two different databases may have different column names for the same actual information (e.g. customer ID vs customer-id).
There may be discrepancies between entries in two different databases for the same actual real-life entity (e.g. for an employee).
Explanation:
Data integration aims at consolidating data from disparate sources into a single dataset provide users with consistent access to data that will meet their various needs. However, the process of data integration faces many challenges. One of the challenges is disparate data formats and sources. There is also the velocity or speed at which data are gathered. For successful data integration, the different datasets need to be cleaned and updated with quality data.
Write a program that launches 1,000 threads. Each thread adds 1 to a variable sum that initially is 0. You need to pass sum by reference to each thread. In order to pass it by reference, define an Integer wrapper object to hold sum. Run the program with and without synchronization to see its effect. Submit the code of the program and your comments on the execution of the program.
Answer:
Following are the code to the given question:
import java.util.concurrent.*; //import package
public class Threads //defining a class Threads
{
private Integer s = new Integer(0);//defining Integer class object
public synchronized static void main(String[] args)//defining main method
{
Threads t = new Threads();//defining threads class object
System.out.println("What is sum ?" + t.s);//print value with message
}
Threads()//defining default constructor
{
ExecutorService exe = Executors.newFixedThreadPool(1000);//defining ExecutorService class object
System.out.println("With SYNCHRONIZATION........");//print message
for(int i = 1; i <= 1000; i++)//defining a for loop
{
exe.execute(new SumTask2());//calling execute method
System.out.println("At Thread " + i +" Sum= " + s + " , ");//print message with value
}
exe.shutdown();//calling shutdown method
while(!exe.isTerminated())//defining while loop that calls isTerminated method
{
}
}
class SumTask2 implements Runnable//calling SumTask2 that inherits Runnable class
{
public synchronized void run()//defining method run
{
int value = s.intValue() + 1;//defining variable value that calls intvalue which is increment by 1
s = new Integer(value);//use s to hold value
}
}
}
Output:
Please find the attached file.
Explanation:
In this code, a Threads class is defined in which an integer class object and the main method is declared that creates the Threads class object and calls its values.
Outside the method, the default constructor is declared that creates the "ExecutorService" and prints its message, and use a for loop that calls execute method which prints its value with the message.
In the class, a while loop is declared that calls "isTerminated" method, and outside the class "SumTask2" that inherits Runnable class and defined the run method and define a variable "value" that calls "intvalue" method which is increment by 1 and define s variable that holds method value.
Validate that the user age field is at least 21 and at most 35. If valid, set the background of the field to LightGreen and assign true to userAgeValid. Otherwise, set the background to Orange and userAgeValid to false.HTML JavaScript 1 var validColor-"LightGreen"; 2 var invalidColor"Orange" 3 var userAgeInput -document.getElementByIdC"userAge"); 4 var formWidget -document.getElementByIdC"userForm"); 5 var userAgeValid - false; 7 function userAgeCheck(event) 10 11 function formCheck(event) 12 if (luserAgeValid) { 13 14 15 16 17 userAgeInput.addEventListener("input", userAgeCheck); 18 formWidget.addEventListener('submit', formCheck); event.preventDefault); 3 Check Iry again
Answer:
Explanation:
The code provided had many errors. I fixed the errors and changed the userAgeCheck function as requested. Checking the age of that the user has passed as an input and changing the variables as needed depending on the age. The background color that was changed was for the form field as the question was not very specific on which field needed to be changed. The piece of the code that was created can be seen in the attached image below.
var validColor = "LightGreen";
var invalidColor = "Orange";
var userAgeInput = document.getElementById("userAge");
var formWidget = document.getElementById("userForm");
var userAgeValid = false;
function userAgeCheck(event) {
if ((userAgeInput >= 25) && (userAgeInput <= 35)) {
document.getElementById("userForm").style.backgroundColor = validColor;
userAgeValid = true;
} else {
document.getElementById("userForm").style.backgroundColor = invalidColor;
userAgeValid = false;
}
};
function formCheck(event) {};
if (!userAgeValid) {
userAgeInput.addEventListener("input", userAgeCheck);
formWidget.addEventListener('submit', formCheck);
event.preventDefault();
}
Write a statement that assigns numCoins with numNickels + numDimes. Ex: 5 nickels and 6 dimes results in 11 coins. Note: These activities may test code with different test values. This activity will perform two tests: the first with nickels = 5 and dimes = 6, the second with nickels = 9 and dimes = 0.
1 import java.util.Scanner;
2
3 public class AssigningSum {
4 public static void main(String[] args) {
5 int numCoins;
6 int numNickels;
7 int numDimes;
8
9 numNickels = 5;
10 numDimes - 6;
11
12 /* Your solution goes here
13
14 System.out.print("There are ");
15 System.out.print(numCoins);
16 System.out.println(" coins");
17 }
18 }
Answer:
Explanation:
The statement solution was added to the code and then the code was repeated in order to create the second test case with 9 nickels and 0 dimes. The outputs for both test cases can be seen in the attached image below.
import java.util.Scanner;
class AssigningSum {
public static void main(String[] args) {
int numCoins;
int numNickels;
int numDimes;
numNickels = 5;
numDimes = 6;
/* Your solution goes here */
numCoins = numNickels + numDimes;
System.out.print("There are ");
System.out.print(numCoins);
System.out.println(" coins");
// TEST CASE 2
numNickels = 9;
numDimes = 0;
/* Your solution goes here */
numCoins = numNickels + numDimes;
System.out.print("There are ");
System.out.print(numCoins);
System.out.println(" coins");
}
}
now now now now mowewweedeeee
Answer:
15
Inside the type declaration, you specify the maximum length the entry can be. For branch, it would be 15.
I can't seem to type the full "vc(15)" phrase because brainly won't let me.
1. Describe data and process modeling concepts and tools.
Answer:
data is the raw fact about its process
Explanation:
input = process= output
data is the raw fact which gonna keeps in files and folders. as we know that data is a information keep in our device that we use .
Answer:
Data and process modelling involves three main tools: data flow diagrams, a data dictionary, and process descriptions. Describe data and process tools. Diagrams showing how data is processed, transformed, and stored in an information system. It does not show program logic or processing steps.
Write code that prints: Ready! userNum ... 2 1 Go! Your code should contain a for loop. Print a newline after each number and after each line of text. Ex: If the input is: 3 the output is: Ready! 3 2 1 Go!
Answer:
Kindly find the code snippet in the explanation written in kotlin language
Explanation:
fun main(args: Array<String>) {
var num:Int
println("Enter a num")
num= Integer.valueOf(readLine())
for(i in num downTo 1){
if(i==num){
print("Ready!")
print(" ")
}
print(i)
print(" ")
if(i==1){
print(" ")
print("Go!")
}
}
}
This function too can also work
fun numTo(num:Int){
if (num>0) for(i in num downTo 1) print("$i ")
println("Go!")
What variable(s) is/are used in stack to keep track the position where a new item to be inserted or an item to be deleted from the stack
Answer:
Hence the answer is top and peek.
Explanation:
In a stack, we insert and delete an item from the top of the stack. So we use variables top, peek to stay track of the position.
The insertion operation is understood as push and deletion operation is understood as entering stack.
Hence the answer is top and peek.
Given two character strings s1 and s2. Write a Pthread program to find out the number of substrings, in string s1, that is exactly the same as s2
Answer:
Explanation:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAX 1024
int total = 0 ;
int n1, n2;
char s1, s2;
FILE fp;
int readf(FILE fp)
{
if((fp=fopen("strings.txt", "r"))==NULL) {
printf("ERROR: can’t open string.txt!\n");
return 0;
}
s1=(char)malloc(sizeof(char)MAX);
if(s1==NULL) {
printf("ERROR: Out of memory!\n");
return 1;
}
s2=(char)malloc(sizeof(char)MAX);
if(s1==NULL) {
printf("ERROR: Out of memory!\n");
return 1;
}
/* read s1 s2 from the file */
s1=fgets(s1, MAX, fp);
s2=fgets(s2, MAX, fp);
n1=strlen(s1); /* length of s1 */
n2=strlen(s2)-1; /* length of s2 */
if(s1==NULL || s2==NULL || n1<n2) /* when error exit */
return 1;
}
int num_substring(void)
{
int i, j, k;
int count;
for(i=0; i<=(n1-n2); i++) {
count=0;
for(j=i, k=0; k<n2; j++, k++){ /* search for the next string of size of n2 */
if((s1+j)!=(s2+k)) {
break;
}
else
count++;
if(count==n2)
total++; /* find a substring in this step */
}
}
return total;
}
int main(int argc, char argv[])
{
int count;
readf(fp);
count=num_substring();
printf("The number of substrings is: %d\n", count);
return 1;
}
_____ is one of the Rs involved in design and implementation of any case-based reasoning (CBR) application.
Answer:
Group of answer choices
React
Reserve
Reason
Retain
I am not sure if its correct
Retain is one of the Rs involved in design and implementation of any case-based reasoning (CBR) application.
What is Case Based Reasoning?Case-based reasoning (CBR) is a known to be a form of artificial intelligence and cognitive science. It is one that likens the reasoning ways as primarily form of memory.
Conclusively, Case-based reasoners are known to handle new issues by retrieving stored 'cases' and as such ,Retain is one of the Rs that is often involved in design and implementation of any case-based reasoning (CBR) application.
Learn more about Retain case-based reasoning from
https://brainly.com/question/14033232
Print the two-dimensional list mult_table by row and column. Hint: Use nested loops.
Sample output with input: '1 2 3,2 4 6,3 6 9':
1 | 2 | 3
2 | 4 | 6
3 | 6 | 9
How can I delete that whitespace?
Answer:
The program is as follows:
[tex]mult\_table = [[1, 2, 3], [2, 4, 6], [3, 6, 9]][/tex]
count = 1
for row in mult_table:
for item in row:
if count < len(row):
count+=1
print(item,end="|")
else:
print(item)
count = 1
Explanation:
This initializes the 2D list
[tex]mult\_table = [[1, 2, 3], [2, 4, 6], [3, 6, 9]][/tex]
This initializes the count of print-outs to 1
count = 1
This iterates through each rows
for row in mult_table:
This iterates through each element of the rows
for item in row:
If the number of print-outs is less than the number of rows
if count < len(row):
This prints the row element followed by |; then count is incremented by 1
count+=1
print(item,end="|")
If otherwise
else:
This prints the row element only
print(item)
This resets count to 1, after printing each row
count = 1
To delete the whitespace, you have to print each element as: print(item,end="|")
See that there is no space after "/"
Answer:
count = 1
for row in mult_table:
for item in row:
if count < len(row):
count+=1
print(item,end=" | ")
else:
print(item)
count = 1
Explanation: Other answers didnt have the spacing correct
Java programming
*11.13 (Remove duplicates) Write a method that removes the duplicate elements from
an array list of integers using the following header:
public static void removeDuplicate(ArrayList list)
Write a test program that prompts the user to enter 10 integers to a list and displays
the distinct integers separated by exactly one space. Here is a sample run:
Enter ten integers: 34 5 3 5 6 4 33 2 2 4
The distinct integers are 34 5 3 6 4 33 2
Answer:
The program in Java is as follows:
import java.util.*;
public class Main {
public static void removeDuplicate(ArrayList<Integer> list){
ArrayList<Integer> newList = new ArrayList<Integer>();
for (int num : list) {
if (!newList.contains(num)) {
newList.add(num); } }
for (int num : newList) {
System.out.print(num+" "); } }
public static void main(String args[]){
Scanner input = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<Integer>();
System.out.print("Enter ten integers: ");
for(int i = 0; i<10;i++){
list.add(input.nextInt()); }
System.out.print("The distinct integers are: ");
removeDuplicate(list);
}}
Explanation:
This defines the removeDuplicate function
public static void removeDuplicate(ArrayList<Integer> list){
This creates a new array list
ArrayList<Integer> newList = new ArrayList<Integer>();
This iterates through the original list
for (int num : list) {
This checks if the new list contains an item of the original list
if (!newList.contains(num)) {
If no, the item is added to the new list
newList.add(num); } }
This iterates through the new list
for (int num : newList) {
This prints every element of the new list (At this point, the duplicates have been removed)
System.out.print(num+" "); } }
The main (i.e. test case begins here)
public static void main(String args[]){
Scanner input = new Scanner(System.in);
This declares the array list
ArrayList<Integer> list = new ArrayList<Integer>();
This prompts the user for ten integers
System.out.print("Enter ten integers: ");
The following loop gets input for the array list
for(int i = 0; i<10;i++){
list.add(input.nextInt()); }
This prints the output header
System.out.print("The distinct integers are: ");
This calls the function to remove the duplicates
removeDuplicate(list);
}}