Answer:
The buffer has room for 499 characters (you always have to reserve 1 for the terminating \0 character).
The code copies all characters passed in the commandline (argv[1]) into this buffer without checking. If there are more than 499 characters supplied, these will be copied into a memory location that is not intended for it. This will probably cause your program to crash, but if the extra data is somehow executed by the processor as if it were a program, this could be a way to sneak a virus into your computer.
So, while copying data, it is important to always limit the maximum amount to the allocated space.
Could someone write the code for this in java? I cannot use java.util random(but i can use scanner). also, i cannot use switch or case.
Program Rock.java contains a skeleton for the game Rock, Paper, Scissors. Add statements to the program as indicated by the comments so that the program asks the user to enter a play, generates a random play for the computer, compares them and announces the winner (and why). For example, one run of your program might look like this:
Enter your play: R, P, or S
r
Computer play is S
Rock crushes scissors, you win!
Note that the user should be able to enter either upper or lower case r, p, and s. Add a loop to make sure the user only enters an R, P, or S. The user's play is stored as a string to make it easy to convert whatever is entered to upper case. Use if statements to convert the randomly generated integer for the computer's play to a string.
public class Rock
{
public static void main(String[] args)
{
String personPlay; //User's play -- "R", "P", or "S"
String computerPlay; //Computer's play -- "R", "P", or "S"
int computerInt; //Randomly generated number used to determine
//computer's play
// Add the code for each action beneath the comment. // more than one line may be needed in some cases // Get player's play -- note that this is stored as a string
// Make player's play uppercase for ease of comparison
// Generate computer's play (0,1,2) – use (int) (Math.random() * 3) to
// generate a random play
// Translate computer's randomly generated play to string // using mutually exclusive conditional statements
// Print computer's play
// See who won. Use nested ifs instead of &&.
}
}
People hardly ever play Rock, Paper, Scissors one game at a time. They play matches that are best 2 out of 3, best 3 out of 5, etc. Change your program to prompt the user for the odd number of games they want to play and use a loop to make sure it is an odd number. Then, add a loop to your program to play the game multiple times. Keep track of who wins, and make sure the loop stops when either the computer or the user has accumulated enough wins. Ties do not count in either the game total or the win totals – so a best 2 out of 3 match requires 3 games to be played where someone wins 2 times.
Program Rock.java contains a skeleton for the game Rock, Paper, Scissors. Open it and save it to your directory.
Add statements to the program as indicated by the comments so that the program asks the user to enter a play,
generates a random play for the computer, compares them and announces the winner (and why). For example, one run
of your program might look like this:
$ java Rock
Enter your play: R, P, or S
r
Computer play is S
Rock crushes scissors, you win!
Note that the user should be able to enter either upper or lower case r, p, and s. The user's play is stored as a
string to make it easy to convert whatever is entered to upper case. Use a switch statement to convert the randomly
generated integer for the computer's play to a string.*/
// ****************************************************************
// Rock.java
//
// Play Rock, Paper, Scissors with the user
//
// ****************************************************************
import java.util.Scanner;
import java.util.Random;
public class Rock
{
public static void main(String[] args)
{
String personPlay; //User's play -- "R", "P", or "S"
String computerPlay; //Computer's play -- "R", "P", or "S"
int computerInt; //Randomly generated number used to determine
//computer's play
Scanner scan = new Scanner(System.in);
Random generator = new Random();
System.out.println ("Enter R for Rock, P for Paper, S for Scissors: "); //Get player's play -- note that this is stored as a string
personPlay = scan.next();
personPlay = personPlay.toUpperCase();
computerInt = generator.nextInt(3);
switch (computerInt)
{
case 0:
{
computerPlay = "R";
break;
}
case 1:
{
computerPlay = "P";
break;
}
case 2:
{
computerPlay = "S";
break;
}
default:
{
computerPlay = "will not happen";
}
}
System.out.println ("Computer plays: " + computerPlay);
if (personPlay.equals(computerPlay))
{
System.out.println("It's a tie!");
}
else if (personPlay.equals("R"))
{
if (computerPlay.equals("S"))
System.out.println("Rock crushes scissors. You win!!");
else if (computerPlay.equals("P"))
System.out.println ("Paper eats rock. You lose!!");
}
else if (personPlay.equals("P"))
{
if (computerPlay.equals("S"))
System.out.println ("Scissor cuts paper. You lose!!");
else if (computerPlay.equals("R"))
System.out.println ("Paper eats rock. You win!!");
}
else if (personPlay.equals("S"))
{
if (computerPlay.equals("P"))
System.out.println ("Scissor cuts paper. You win!!");
else if (computerPlay.equals("R"))
System.out.println ("Rock breaks scissors. You lose!!");
}
else
{
System.out.println ("Invalid user input.");
}
}
}
// Enter R for Rock, P for Paper, S for Scissors:
// P
// Computer plays: P
// It's a tie!
9. In a program with 25% loads, 10% stores, 11% branches, 2% jumps, 52% R-type. The standard CPI for each instruction type is 2 cycles loads, 2 cycles stores, 1 cycle branches, 2 cycles jumps, 1 cycle R-type. The branches have a misprediction penalty of an additional 2 cycles when it misses, which happens 30% of the time. Loads create a RAW hazard 20% of the time adding in an extra cycle to the execution time. What is the average CPI for this program on this processor
Answer:
2.6
Explanation:
Which of these statements are true about Domain Controllers (DCs)? Check all that apply.
Changes that are safe to be made by multiple Domain Controllers at once are tasked by granting them Flexible Single-Master Operations.
The default Organizational Unit (OU) called Domain Controllers contains all Domain Controllers in the domain.
Delegation can be used in Active Directory.
You should always use your Domain Admin or Enterprise Admin for day-to-day use.
A domain controller is known to be a type of computer server that often responds to security authentication requests and verifies users. The true statements about Domain Controllers (DCs) are:
The default Organizational Unit (OU) called Domain Controllers contains all Domain Controllers in the domain. Delegation can be used in Active Directory.Default user groups often do exist. The Domain Controllers user group has all Domain Controllers in the domain.
Delegation can be used in Active Directory as they help to give accounts permission in the file system so that an individual can set Access.
Learn more from
https://brainly.com/question/24931494
Which two wireless technologies are used in IoT?
Answer:
If you like my answer you can put me in brainlist.
Explanation:
LPWANs. Low Power Wide Area Networks (LPWANs) are the recent development specifically designed for the requirements for IoT. ...
Cellular (4G and 5G) ...
Zigbee and Other Mesh Protocols. ...
Bluetooth and BLE. ...
Wi-Fi. ...
RFID.
Hope this is helpful to you.....
Encryption is an effective strategy to prevent which of the following?
O eavesdropping
O jamming
O destruction of data
O tapping
What are different method of selecting items??
Answer:
Hold down the "Ctrl" key and the "Shift" key. Press the right arrow key to select the word to the right, or press the left arrow key to select the word to the left. Select one character at a time by holding down the "Shift" key and and using either arrow key (right or left).
Explanation:
follow= return follow
A computer uses
to follow a set of instructions
Answer:
A set of instructions that directs a computer's hardware to perform a task is called a program, or software program.
Answer:
which is called a program
Explanation:
Động cơ đốt trong có mấy loại
động có xăng, động cơ diesel và động cơ gas còn gọi là động cơ chạy khí
What allows an individual to avoid capital outlay?
paying cloud by the month
paying cloud by the year
paying cloud by the hour
paying cloud by the day
The daily payment for cloud services would be most reasonable. Hence option A is correct.
Capital Outlay refers to the expenditure or payment for the acquisition cost of capital assets.
In this case, the assets whose cost of purchase is being avoided by expenditure on cloud services is IT Server Hardware and Software which can be outsourced to companies that provide Cloud as a Service.
Cloud Services is the provision of Cloud computing services on a pay-per-use basis.
One of the advantages of this service is that it mostly consists of self-service on-demand. Hence, no need for the physical asset which usually is very costly.
Learn more about Capital Outlay in the link below:
https://brainly.com/question/832717
Give an example (other than clothes) where the must-have feature could be APPEARANCE.
Answer:
Assuming you are talking about UI or something graphical on a computer screen we'll just say the must-have features (in terms of appearance) are:
The UI/Web/Graphical Designers basic knowledge of color theory so they don't end up putting #0000FF text on a #FF0000 backgroundA good font (if there is text) that looks nice with the colors usedA proper aesthetic to the software (I.E. Spotify's green on black modern/techno aesthetic)The design of mobile phones is an example of a must-have feature that is in appearance.
What are the features of appearance?Features of appearance mean the visual qualities of an object or product.
Such as:
- Color
- Shape
- Texture
- Finish
- Branding
We have,
One example where the must-have feature could be appearance is in the mobile phones design
Many consumers prefer mobile phones that not only have the latest technology and features but also look sleek and stylish.
Companies invest heavily in the design of their mobile phones to make them visually appealing to consumers.
The appearance of the phone can often be a deciding factor in the purchasing decision, even if the phone has similar features to a competitor.
Thus,
The design of mobile phones is an example of a must-have feature that is in appearance.
Learn more about appearance here:
https://brainly.com/question/15851729
#SPJ2
Write a program that prompts the user to enter the month and year and displays the number of days in the month. For example, if the user entered month 2 and year 2000, the program should display that February 2000 has 29
Answer:
5
Explanation:
becauss it is impossible to actually di
Which wireless standard runs on both the 2.4 and 5 GHz frequencies?
Answer:
Approved in 2009, Wi-Fi 4 enables operation in both the 2.4 and 5 GHz frequencies, a game changer at the time. It was the first standard to use MIMO (Multiple In, Multiple Out) and offered better speed, 300 Mbps, better range, more resistance to interference and backward compatibility with Wi-Fi 2 and
Hope this is helpful to you.......
beth chooses fresh vegetables every time she does marketing. she pares and cuts right away these vegetable considering that they are fresh. the moment she serves the appetizer, she washes the plate and uses it without drying. what statement best describes the situation inside teh box
Answer:
spell correctly "teh=the
Explanation:
beth chooses fresh vegetables every time she does marketing. she pares and cuts right away these vegetable considering that they are fresh. the moment she serves the appetizer, she washes the plate and uses it without drying. what statement best describes the situation inside teh box
state two advantage of using the internet
Answer:
Seemless communication with other parts of the world
Being able to share files easily
Explanation:
Answer:
communicate with family.
Able to get information from the internet.
State true/false. When shortcut assignment operators are used, then we first write the assignment operator and then the arithmetic operator.
Answer:
true
Explanation:
When shortcut assignment operators are used, then we first write the assignment operator and then the arithmetic operator.
From her stack of photographs, Alice has to pick images that a photographer shot using the sports mode. Which images would she pick?
Answer:
1. horses
2. train/ metro
3. child
Which of these lines of code will generate a random number between 1 and 50? A. input("1-50") B. print("1-50") C. import random D. num = random.randint(1,50)
Answer:
D. num = random.randint(1,50)
Explanation:
The option given above will assign a random integer in the range of 1 through 50 to the variable number is: "number = random.randint(1, 50)"
What is a random integer in programming?This is a random sequence of integers that may be used to imitate things like shuffling a deck of cards or creating distinct behaviors every time a program runs. The RND function in BASIC generates random numbers. This yields a value between 0 and 1.
Random number creation is a technique that generates a series of numbers or symbols that cannot be realistically anticipated better than by random chance, generally using a random number generator (RNG).
Therefore, The option given above will assign a random integer in the range of 1 through 50 to the variable number is: "number = random.randint(1, 50)"
Learn more about random integers:
brainly.com/question/15247918
#SPJ3
a) Viết chương trình tính tổng từ 20 – 50
b) Viết chương trình tính tổng từ a – b, với a, b nhập từ bàn phím. Yêu cầu: a
không phải thông báo lỗi.
cứu tôi 2 câu này sài lệnh lặp
Answer:
Program viet_chuong_trinh_tinh_tong;
Uses Crt;
Var i,s:integer;
Begin
Clrscr;
i:=20;
While (i>=20) and (i<=50) do
Begin
s:=s+i;
i:=i+2;
End;
Writeln(S);
Readln;
End.
Explanation:
what is multimedia software
Answer: A program that plays or records audio files or playing or recording video files. Audio of famous speeches is a multimedia software
Explanation:
Uhaul general mechanical questions 2021
Not a question. But the answers.
1) The PRIMARY purpose of the dual rear tires on this truck is to: (A) Reduce the chance of a blowout. (B) Withstand a heavier load and add greater stability. (C) Add more weight to the rear of the truck.
B
2) Which of these tools should be used on a Phillips-head screw?
B
3) Which arrow points to the alternator?
C
4) With the truck backing up and the front tires turned as shown, which way will the rear of the truck swing?
A
5) Above are four tools. Three of the tools have a similar function while one is different. Which tool performs the most different function of the four tools?
D
6) Which scaffolding above could probably hold more weight?
B
7) Which refrigerator will be easier to roll over uneven ground?
A
8) Assuming the pick-up trucks, trailers and road conditions are exactly the same, which vehicle will take a longer distance to stop?
B
9) What is the proper battery cable connection when jumping two automotive batteries? (A) Negative to Negative / Positive to Positive (B) Negative to Positive / Negative to Positive (C) It doesn't matter on 12-volt automotive batteries
A
10) Which of these filters is associated with airflow?
A
11) If a box of clothes weighing 10 lbs (4.5 kg) and a box of books weighing 10 lbs (4.5 kg) were placed on a scale, what is most likely to occur?
C
12) Which area will get the smoothest ride?
B
13) Which trailer has more downward pressure where it attaches to the car?
A
14) Which direction will wheel three rotate?
B
15) The tire above has a recommended tire pressure of 35 PSI, however, its current pressure is only 26 PSI. Which of the following could occur if driven on? (A) A tire blowout. (B) Unstable handling of the vehicle. (C) Both A & B.
C
16) Which is the proper position of the adjustable wrench for tightening a nut?
A
17) Which tire has more tread? (A) Image A (B) Image B (C) Cannot be determined
B
18) Which picture best illustrates the correct location for loading ONLY the washer in this trailer?
B
19) Which is the MOST LIKELY use for the following object? (A) Checking for a vacuum source. (B) Checking for the proper voltage at the battery. (C) Checking for electrical current traveling through a wire.
C
20) If this truck backs up with the front tires turned as shown, which way will the rear of the trailer swing?
B
21) Which illustration best demonstrates the safest ladder for this person to use?
A
22) Which method requires the least amount of effort to move the refrigerator?
A
23) With the side gears turning in the direction shown, in which direction will the top gear turn?
B
24) In order for the Hitch ball to be secured properly, what should be the last part assembled? (A) Nut (B) Shank (C) Cotter Pin
C
25) As the truck backs up, which way should the front tires be turned in order to make the trailer follow the road?
B
Moving or transportation tools, equipment and methods provides guidance
on the safe an efficient ways to move items.
The correct responses are;
1) (B); 2) B; 3) C; 4) A; 5) D; 6) B; 7) A; 8) B; 9) (A); 10) A; 11) C; 12) B; 13) A; 14) A; 15) B; 16) A; 17) B; 18) A; 19) (C); 20) B; 21) B; 22) A; 23) B; 24) (C); 25) B
Reasons:
1) The correct option is; (B) Withstand a heavier load and add greater stability
By sing two wheels on the rear of a truck, heavy loads can be hauled, and transported around corners, and bumpy roads, reducing the possibility of the load tipping the truck over, thereby keeping the truck stable.2) The correct option is; B
The Phillips-head screw is cross shaped, and required a cross shaped screwdriver, which is option B)3) The correct option is; C
The alternator converts mechanical rotational energy into electrical energy, and usually has a compact electrical coil and magnets within its enclosure. The alternator is option C4) The correct option is; A
The rear of a truck moves in the direction the front tires are turned5) The correct option is; D
Option A and B are pliers, while option B is a spanner, all of which are used to fasten and loosen bolts and nuts. Option D is a screwdriver used to fasten and loosen screws.6) The correct option is; B
The working platform on scaffold B has extra support from the diagonal braces.7) The correct option is; A
The large size tires in refrigerator A increases the contact surface with the road to prevent entering into small holes8) The correct option is; B
Due to the heavier load in the trailer of pick-up truck B, more force is required, to stop the truck according to Newton's Laws of motion, and therefore, a longer distance will be taken to stop by the truck, given similar conditions (magnitude) stopping force available9) The correct option is; (A)
Jumping two batteries to start an automotive with a dead battery requires a Negative to Negative / Positive to Positive connection, which is option (A)10) The correct option is; A
The air filter will have a open outer rim for the free passage of air.11) The correct option is; C
The scale measures the difference in weight, and the weight depends on the mass of the item. Given that the mass are equal, both weights would be equal, and therefore, the scale would be level.12) The correct option is; B
The smoothest ride is closest to the most weight of the vehicle, which is located in the front, therefore, the area that gets the smoothest ride is option B13) The correct option is; A
The downward pressure is given by the location of the load relative to the wheel on the trailer, that gives either a clockwise or downward moment of force when in position of option A or a counterclockwise or upward moment at B14) The correct option is; A
Gear connected by belt or chain move in the same direction, therefore, the direction of wheel 3 is option A15) The correct option is; B
A tire blowout will not occur because, the pressure is below the recommended pressure. However, the motion of the car will be unstable16) The correct option is; A
When tightening a nut with an adjustable wrench, the direction of turning the wrench is towards the movable jaw, therefore, the option A is correct17) The correct option is; B
The difference between the threads of the given tires is the depth of their grooves, therefore, the tire in option B has more thread.18) The correct option is; A
When loading items on a trailer, the majority of the load should be located in the front, therefore, the correct location for loading only the washer is illustrated by the picture A.19) The correct option is; (C)
The object has a lead, an insulated handle, and a electrical bulb that lights up when there is electricity, therefore, it is used for (C) Checking for electrical current travelling through a wire.20) The correct option is; B
The trailer swings in the opposite direction to the truck.21) The correct option is; B
The ladder in picture B is safer because it spreads more at the base22) The correct option is; A
Most of the weight of the refrigerator act on the wheel in picture A than in picture B23) The correct option is; B
The gear turns towards the screen on the left and away from the screen on the right, which is a direction from left to right.24) The correct option is; (C)
The cotter pin is assembled last to hold the bolt in place, and cannot be assembled before the other parts as it will restrict their movement25) The correct option is; B
The front tire should be turned in the opposite direction to the intended direction of the trailer.
Learn more here:
https://brainly.com/question/69628
limitations of systems analysis and design
Answer:
Explanation:
Although System analysis offers an extensive range of benefits it might also have some disadvantages. One of the main disadvantages which is mostly overlooked is the risk of too much analysing which may be costly and time consuming. It is therefore part of the analyst's job to find the right balance.If ADD = 81, BAD = 49, and CAD = 64, then what is the value of ACA?
Answer:
its 72
Explanation:
i know it because i did it and thats how i know it
Technology negative impact on sustainability
what is computer managers
Answer:
Computer managers are responsible for overseeing the computer system of a company. Their work involves planning, coordinating, and organizing the computer-related activities within a firm. Computer managers develop and implement a company's information technology (IT) goals and objectives.
Answer:
Responsible for overseeing the computer system of a company .
Does media contribute to the mental wellness of society?
Answer:
However, multiple studies have found a strong link between heavy social media and an increased risk for depression, anxiety, loneliness, self-harm, and even suicidal thoughts. Social media may promote negative experiences such as: Inadequacy about your life or appearance.
What is mean by SEO?
Answer:
SEO = Search Engine Optimization
Answer:
Search Engine Optimization
Explanation:
Is the process used to optimize a website's technical configuration, content relevance and link popularity so its pages can become easily findable, more relevant and popular towards user search queries, and as a consequence, search engines rank them better.
three types of query
It is commonly accepted that there are three different types of search queries:
Navigational search queries.
Informational search queries.
Transactional search queries.
a simple C program to find the logarithm of any number in any base.....
Answer:
tera bur mast hai jwjvszvVbzNjz
Which is faster, CL3 memory or CL5 memory?
Answer:
CL3. When dealing with CL or RL ratings, the lower the better.
Explanation:
I hope this helps!
5. Power Trio
by CodeChum Admin
Multiplying two numbers is a piece of cake, but how about multiplying three of them, either being a negative of positive number? With programming and proper code, these tasks are easy to handle.
You're a programmer, right? Then code this one for me!
Input
A line containing three numbers (positive or negative, may have decimal places) separated by a space.
1.6·-2·-1
Output
A line containing a decimal/float with one decimal place.
3.2
Answer:
from decimal import *
li = list(map(Decimal,input().split()))
result = li[0]*li[1]*li[2]
print(abs(result))
Explanation:
The proper or programming code to handle that multiplies three numbers is as follows:
from decimal import *
value = list(map(Decimal,input().split()))
result = value[0]*value[1]*value[2]
print(abs(result))
Code explanation:The code is written in python.
From the decimal module we have to import *. The decimal module incorporates a notion of significant places so that 1.3*1.2 = 1.56The variable value is used to store the list of the decimal inputThe variable result multiplies the three numbers in the list Finally we print the absolute value of the result.learn more on python here: https://brainly.com/question/19175881