Answer:
Hmm, I think it is true
Explanation:
Given main(), complete the Car class (in file Car.java) with methods to set and get the purchase price of a car (setPurchasePrice(), getPurchasePrice()), and to output the car's information (printInfo()).
Ex: If the input is:
2011
18000
2018
where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, the output is:
Car's information:
Model year: 2011
Purchase price: 18000
Current value: 5770
Note: printInfo() should use three spaces for indentation.
Answer and Explanation:
public class Main {
int Carmodel;
int Purchaseprice;
int Currentyear;
Public void setPurchasePrice(int Purchaseprice){
this.Purchaseprice=Purchaseprice;
}
Public void getPurchasePrice(){
return Purchaseprice;
}
static void printInfo(int Carmodel int Currentyear ){
this.Carmodel=Carmodel;
this.Currentyear=Currentyear;
System.out.println(getPurchasePrice() Carmodel Currentyear);
}
}
The above java program defines a class that has three methods, a get method that returns purchase price of the object, a set method that sets purchase price of the object, and a print method that print out the information about the car object(model, year, price). The print method also takes arguments and assigns values of the arguments/parameters to the object, then prints all.
Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the print member function and a separate cout statement to output courseStudents's data. End with a newline. Sample output from the given program:
#include
#include
using namespace std;
class PersonData {
public:
void SetName(string userName) {
lastName = userName;
};
void SetAge(int numYears) {
ageYears = numYears;
};
// Other parts omitted
void PrintAll() {
cout << "Name: " << lastName;
cout << ", Age: " << ageYears;
};
private:
int ageYears;
string lastName;
};
class StudentData: public PersonData {
public:
void SetID(int studentId) {
idNum = studentId;
};
int GetID() {
return idNum;
};
private:
int idNum;
};
int main() {
StudentData courseStudent;
/* Your solution goes here */
return 0;
}
Answer:
Replace /* Your solution goes here */
with the following:
courseStudent.SetName("Smith");
courseStudent.SetAge(20);
courseStudent.SetID(9999);
courseStudent.PrintAll();
cout <<courseStudent.GetID();
Explanation:
From the given code segment, we have the following methods defined under the StudentData class;
SetName -> It receives name from the main
SetAge -> It receives age from the main
SetID --> It receives ID from the main and passes it to GetID method
printID --> Prints all the required output.
So, we have:
Pass name to setName
courseStudent.SetName("Smith");
Pass age to setAge
courseStudent.SetAge(20);
Pass ID to setID
courseStudent.SetID(9999);
Print all necessary outputs
courseStudent.PrintAll();
Manually print the student ID
cout <<courseStudent.GetID();
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.
Select the correct statement(s) regarding decentralized (distributed) access control on a LAN. a. no centralized access process exists, and therefore each connected station has the responsibility for controlling its access b. data collisions are possible, therefore mechanisms such as CDMA/CD are required c. when a data collision occurs, the nearest station detecting the collision transmits a jamming signal d. all of the above are correct
Answer: D. all of the above are correct
Explanation:
The correct statements regarding the decentralized (distributed) access control on a LAN include:
• no centralized access process exists, and therefore each connected station has the responsibility for controlling its access
• data collisions are possible, therefore mechanisms such as CDMA/CD are required
• when a data collision occurs, the nearest station detecting the collision transmits a jamming signal.
Therefore, the correct option is all of the above.
What Are the Benefits of Using Leads Automation Tool?
Answer:
Here are the top benefits of using the latest leads automation tool for your personal pursuit, professional service, and other types of businesses.
Frees Up A Lot of Time & ResourcesCompound Connection Growth StrategyViewing ProfilesSending Connection RequestsEndorses Skills of Your First Level ContactsBuild your networkImportance of Leads Automation Tool For LinkedIn
Unlike a traditional and non-automation approach, the best LinkedIn leads automation tool 2020 makes the process far more easier and efficient. It helps to win a good number of connections which would eventually make it easier for businesses to pitch their products and turn newly gained connections into potential customers.
Moreover, businesses will also get more views and new messages in your LinkedIn inbox. The best leads automation tool free are especially useful when you have multiple LinkedIn accounts as you will get rid of time-consuming hectic tasks.
Complete the calcAverage() method that has an integer array parameter and returns the average value of the elements in the array as a double.(Java program)
Ex: If the input array is:
1 2 3 4 5
then the returned average will be:
3.0
Answer:
Explanation:
The following Java program has the method calcAverage(). It creates a sum variable which holds the sum of all the values in the array and the count variable which holds the number of elements in the array. Then it uses a For Each loop to loop through the array and go adding each element to the sum variable. Finally it calculates the average by dividing the sum by the variable count and returns the average to the user. A test case has been created in the main method using the example in the question. The output can be seen in the image attached below.
class Brainly {
public static void main(String[] args) {
int[] myArr = {1, 2, 3, 4, 5};
System.out.println(calcAverage(myArr));
}
public static double calcAverage(int[] myArr) {
double sum = 0;
double count = myArr.length;
for (int x: myArr) {
sum += x;
}
double average = sum / count;
return average;
}
}
Large computer programs, such as operating systems, achieve zero defects prior to release. Group of answer choices True False PreviousNext
Answer:
The answer is "False"
Explanation:
It is put to use Six Sigma had 3.4 defects per million opportunities (DPMO) from the start, allowing for a 1.5-sigma process shift. However, the definition of zero faults is a little hazy. Perhaps the area beyond 3.4 DPMO is referred to by the term "zero faults.", that's why Before being released, large computer programs, such as operating systems, must have no faults the wrong choice.
Using Python suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
You are given a target value to search. If found in the array return its index, otherwise return “The input is not on this list”
You may assume no duplicate exists in the array.
Hint: Use a function. Use the built in method .index( ) and/or for loops.
Answer:
Explanation:
class Solution {
public int search(int[] nums, int target) {
int n = nums.length;
int low = 0 , high = n - 1;
While(low < high){//Set virtual node
int mid = (low + high) / 2;
if(nums[mid] > nums[high]){
low = mid + 1;
}else{
high = mid;
}
}
int rot = low;
low = 0;
high = n - 1;
while(low <= high){
int mid = (low + high) / 2;
Int real = (mid + rot) % n;//The virtual node is mapped to the real node.
if(nums[real] == target){
return real;
}else if(nums[real] < target){
low = mid + 1;
}else{
high = mid - 1;
}
}
return -1;
}
}
????????????????????????????????
(c) 4
Explanation:The function strpos() is a function in php that returns the position of the first occurrence of a particular substring in a string. Positions are counted from 0. The function receives two arguments. The first argument is the string from which the occurrence is to be checked. The second argument is the substring to be checked.
In this case, the string is "Get Well Soon!" while the substring is "Well"
Starting from 0, the substring "Well" can be found to begin at position 4 of the string "Get Well Soon!".
Therefore, the function strpos("Get Well Soon!", "Well") will return 4.
Then, with the echo statement, which is used for printing, value 4 will be printed as output of the code.
Indicate whether the following actions are the actions of a person who will be a victim, or will not be a victim, of phishing attacks.
Replying to an e-mail requesting your user ID and password Phishing victim Not a phishing victim
Answer:
Phishing Victim
Explanation:
Replying to this email could make you a victim of a phishing scam. Phishing attacks are common challenges on security that internet users are faced with. It could lead to others getting hold of sensitive information like your password or bank details. email is one way the hackers used to get this information. replying to such an email could lead one to an unsecure website where information could be extracted
Calculate how much disk space (in sectors, tracks, and surfaces) will be required to
store 300,000 120-byte logical records if the disk is fixed sector with 512 bytes/
sector, with 96 sectors/track, 110 tracks per surface, and 8 usable surfaces. Ignore
any file header record(s) and track indexes, and assume that records cannot span
two sectors.
It will be great if you could explain the answer to me. :)
Answer:
see your answer in image
mark me brainlist
The amount of disk space in sectors that would be required to store 300,000 records is equal to 75,000 sectors.
Given the following data:
Number of records = 300,000.Size of each logical record = 120 byte.Number of bytes (sector) = 512.Number of sectors per track = 96.Number of tracks per surface = 110.How to calculate the required disk space?First of all, we would determine the number of logical records that can be held by each sector as follows:
Number of logical records per sector = 512/120
Number of logical records per sector = 4.3 ≈ 4.0.
Now, we can calculate the required disk space to store 300,000 records:
Disk space = 300,000/4
Disk space = 75,000 sectors.
For the tracks, we have:
Disk space in tracks = 75,000/96
Disk space in tracks = 781.25 ≈ 782.
Disk space in tracks = 782 tracks.
For the surfaces, we have:
Disk space in surfaces = 782/110
Disk space in surfaces = 7.10 ≈ 8.
Disk space in surfaces = 8 surfaces.
Read more on disk space here: https://brainly.com/question/26382243
Ms. Lawson, a primary school teacher, told her students that a photograph of the president is in the public domain. What does she mean by this?
Answer:
He belongs to the nation
Using the concepts of public and private domains, it means that the photograph of the president can be used by anyone without asking for permission.
---------------
Public and private domains:
If an image is of private domain, there is the need to ask the owner for the right to use the image.If it is of public domain, there is no need, as is the case for the president photo in this question.A similar question is given at https://brainly.com/question/12202794
SQLite is a database that comes with Android. Which statements is/are correct?
The content of an SQLite database is stored in XML formatted files because XML is the only file format supported by Android OS.
A SQLite database is just another name for a Content Provider. There is no difference as the SQLite implementation implements the Content Provider interface.
If an app creates an SQLite database and stores data in it, then all of the data in that particular database will be stored in one, single file.
A database query to an SQLite database usually returns a set of answers
To access individual entries, SQLite provides a so-called Cursor to enumerate all entries in the set.
This is yet another example of the Iterator pattern.
Answer:
1. Wrong as per my knowledge, SQLite may be an electronic database software that stores data in relations(tables).
2. Wrong. Content provider interface controls the flow of knowledge from your android application to an external data storage location. Data storage is often in any database or maybe it'll be possible to store the info in an SQLite database also.
3.Right. SQLite uses one file to store data. It also creates a rollback file to backup the stored data/logs the transactions.
4. Wrong. The queries are almost like a traditional electronic database system, the queries are going to be answered as per the conditions given and should return a group of answers or one answer depending upon the info and sort of query used.
5. Right. A cursor helps to point to one entry within the database table. this may be very helpful in manipulating the present row of the query easily.
Write a function that takes six arguments of floating type (four input arguments and two output arguments). This function will calculate sum and average of the input arguments and storethem in output arguments respectively. Take input arguments from the user in the main function.
Answer:
Answer:Functions in C+
The integer variable n is the input to the function and it is also called the parameter of the function. If a function is defined after the main() .....
A(n) _____ is a network connection device that can build tables that identify addresses on each network.
Answer:
Dynamic Router
Explanation:
A dynamic router is a network connection device that can build tables that identify addresses on each network.
What is Dynamic network?Dynamic networks are networks that vary over time; their vertices are often not binary and instead represent a probability for having a link between two nodes.
Statistical approaches or computer simulations are often necessary to explore how such networks evolve, adapt or respond to external intervention.
DNA statistical tools are generally optimized for large-scale networks and admit the analysis of multiple networks simultaneously in which, there are multiple types of nodes (multi-node) and multiple types of links (multi-plex).
Therefore, A dynamic router is a network connection device that can build tables that identify addresses on each network.
To learn more about dynamic router, refer to the link:
https://brainly.com/question/14285971
#SPJ6
how to Write a simple Java socket programming that a client sends a text and server receives and print.
Answer:
Java Socket programming is used for communication between the applications running on different JRE.
Java Socket programming can be connection-oriented or connection-less.
Socket and ServerSocket classes are used for connection-oriented socket programming and DatagramSocket and DatagramPacket classes are used for connection-less socket programming.
The client in socket programming must know two information:
IP Address of Server, and
Port number.
Here, we are going to make one-way client and server communication. In this application, client sends a message to the server, server reads the message and prints it. Here, two classes are being used: Socket and ServerSocket. The Socket class is used to communicate client and server. Through this class, we can read and write message. The ServerSocket class is used at server-side. The accept() method of ServerSocket class blocks the console until the client is connected. After the successful connection of client, it returns the instance of Socket at server-side.
Explanation:
Creating Client:
import java.io.*;
import java.net.*;
public class MyServer {
public static void main(String[] args){
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection.
DataInputStream dis=new DataInputStream(s.getInputStream());
Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a newline and decare/use loop variable. Example output for numCycles = 2:
1: Lather and rinse.
2: Lather and rinse.
Done.
import java.util.Scanner; 3 public class ShampooBottle 4 5 Your solution goes here / 7 public static void main (String [] args) ShampooBottle trialSize - new ShampooBottle); trialsize.printShampooInstructions (2) 10 Run View your last submission Your solution goes here / public void printShampooInstructions (int numCycles) f if (numCycles 1) System.out.printin("Too few.") else if (numCycles4) System.out.printin("Too many.") else System.out.println("Done."); for (int i = 1; i (z numCycles ; ++i){ System.out . printin (? + ": Lather and rinse.");
Answer:
if (numCycles < 1){
System.out.println("Too few.");
}
else if (numCycles > 4){
System.out.println("Too many.");
}
else{
for(int i = 1; i <= numCycles; i++)
{
System.out.println(i + ": Lather and rinse.");
}
System.out.println("Done.");
}
Explanation:
List safety conditions when downloading shareware, free free where, or public domain software
Answer:
Explanation:
Freeware and shareware programs are softwares which are either free of charge or consist of a free version for a certain trial period. These programs pose a threat of habouring malware or viruses which could damage one's computer and important files and programs. Therefore, it is imperative that carefulness is maintained when trying to get these softwares.
Some of the necessary safety conditions that should be taken include;
1) Appropriate research about the software including taking more about the vendors and reviews.
2.) Once, a healthy review has been identified ; the download can begin with the Downloader ensuring that the download is from the recommended site.
3) Prior to installation the software should be scanned with an active anti-virus program to determine if there is possibility that a virus has creeped in.
4.) Some softwares may require that computer anti-virus be turned off during installation, this is not always a good idea as this act leaves the system vulnerable a d badly exposed.
Modeling and simulation can enhance the Systems Engineering process by:__________.
a. Helping IPT members to understand the interrelationship of components without physically changing the system.
b. Providing designs that will consistently exceed functional capabilities.
c. Quickly providing physical solutions to meet functional capabilities.
d. Eliminating technical risk before production begins.
Write a removeDuplicates() method for the LinkedList class we saw in lecture. The method will remove all duplicate elements from the LinkedList by removing the second and subsequent elements. If there is only one copy of an element, it is not removed. The list size should shrink accordingly based on the number of duplicates removed.
Answer:
removeDuplicates() function:-
//removeDuplicates() function removes duplicate elements form linked list.
void removeDuplicates() {
//declare 3 ListNode pointers ptr1,ptr2 and duplicate.
//initially, all points to null.
ListNode ptr1 = null, ptr2 = null, duplicate = null;
//make ptr1 equals to head.
ptr1 = head;
//run while loop till ptr1 points to second last node.
//pick elements one by one..
while (ptr1 != null && ptr1.next != null)
{
// make ptr2 equals to ptr1.
//or make ptr2 points to same node as ptr1.
ptr2 = ptr1;
//run second while loop to compare all elements with above selected element(ptr1->val).
while (ptr2.next != null)
{
//if element pointed by ptr1 is same as element pointed by ptr2.next.
//Then, we have found duplicate element.
//Now , we have to remove this duplicate element.
if (ptr1.val == ptr2.next.val)
{
//make duplicate pointer points to node where ptr2.next points(duplicate node).
duplicate = ptr2.next;
//change links to remove duplicate node from linked list.
//make ptr2.next points to duplicate.next.
ptr2.next = duplicate.next;
}
//if element pointed by ptr1 is different from element pointed by ptr2.next.
//then it is not duplicate element.
//So, move ptr2 = ptr2.next.
else
{
ptr2 = ptr2.next;
}
}
//move ptr1 = ptr1.next, after check duplicate elements for first node.
//Now, we check duplicacy for second node and so on.
//so, move ptr1 by one node.
ptr1 = ptr1.next;
}
}
Explanation:
Complete Code:-
//Create Linked List Class.
class LinkedList {
//Create head pointer.
static ListNode head;
//define structure of ListNode.
//it has int val(data) and pointer to ListNode i.e, next.
static class ListNode {
int val;
ListNode next;
//constructor to create and initialize a node.
ListNode(int d) {
val = d;
next = null;
}
}
//removeDuplicates() function removes duplicate elements form linked list.
void removeDuplicates() {
//declare 3 ListNode pointers ptr1,ptr2 and duplicate.
//initially, all points to null.
ListNode ptr1 = null, ptr2 = null, duplicate = null;
//make ptr1 equals to head.
ptr1 = head;
//run while loop till ptr1 points to second last node.
//pick elements one by one..
while (ptr1 != null && ptr1.next != null)
{
// make ptr2 equals to ptr1.
//or make ptr2 points to same node as ptr1.
ptr2 = ptr1;
//run second while loop to compare all elements with above selected element(ptr1->val).
while (ptr2.next != null)
{
//if element pointed by ptr1 is same as element pointed by ptr2.next.
//Then, we have found duplicate element.
//Now , we have to remove this duplicate element.
if (ptr1.val == ptr2.next.val)
{
//make duplicate pointer points to node where ptr2.next points(duplicate node).
duplicate = ptr2.next;
//change links to remove duplicate node from linked list.
//make ptr2.next points to duplicate.next.
ptr2.next = duplicate.next;
}
//if element pointed by ptr1 is different from element pointed by ptr2.next.
//then it is not duplicate element.
//So, move ptr2 = ptr2.next.
else
{
ptr2 = ptr2.next;
}
}
//move ptr1 = ptr1.next, after check duplicate elements for first node.
//Now, we check duplicacy for second node and so on.
//so, move ptr1 by one node.
ptr1 = ptr1.next;
}
}
//display() function prints linked list.
void display(ListNode node)
{
//run while loop till last node.
while (node != null)
{
//print node value of current node.
System.out.print(node.val + " ");
//move node pointer by one node.
node = node.next;
}
}
public static void main(String[] args) {
//Create object of Linked List class.
LinkedList list = new LinkedList();
//first we create nodes and connect them to form a linked list.
//Create Linked List 1-> 2-> 3-> 2-> 4-> 2-> 5-> 2.
//Create a Node having node data = 1 and assign head pointer to it.
//As head is listNode of static type. so, we call head pointer using class Name instead of object name.
LinkedList.head = new ListNode(1);
//Create a Node having node data = 2 and assign head.next to it.
LinkedList.head.next = new ListNode(2);
LinkedList.head.next.next = new ListNode(3);
LinkedList.head.next.next.next = new ListNode(2);
LinkedList.head.next.next.next.next = new ListNode(4);
LinkedList.head.next.next.next.next.next = new ListNode(2);
LinkedList.head.next.next.next.next.next.next = new ListNode(5);
LinkedList.head.next.next.next.next.next.next.next = new ListNode(2);
//display linked list before Removing duplicates.
System.out.println("Linked List before removing duplicates : ");
list.display(head);
//call removeDuplicates() function to remove duplicates from linked list.
list.removeDuplicates();
System.out.println("")
//display linked list after Removing duplicates.
System.out.println("Linked List after removing duplicates : ");
list.display(head);
}
}
Output:-
Which symbol is used to identify edge-triggered flip-flops
Answer:
A triangle on the Clock input.
Definition of digital
Answer:
There are two definitions from
Explanation:
1.) (of signals or data) expressed as series of the digits 0 and 1, typically represented by values of a physical quantity such as voltage or magnetic polarization.
2.) (of a clock or watch) showing the time by means of displayed digits rather than hands or a pointer.
I'm not sure if you meant "Digit". But if you did it would mean numbers or the places where numbers would go.
Hope this helps! (If not so sorry)
Answer:
adjective
1.
(of signals or data) expressed as series of the digits 0 and 1, typically represented by values of a physical quantity such as voltage or magnetic polarization.
relating to, using, or storing data or information in the form of digital signals.
"digital TV"
involving or relating to the use of computer technology.
"the digital revolution"
Which of the following restricts the ability for individuals to reveal information present in some part of the database?
a. Access Control
b. Inference Control
c. Flow Control
d. Encyption
Answer:
it would have to be flow control which would be C.
Explanation:
Flow Control is restricts the ability for individuals to reveal information present in some part of the database. Hence, option C is correct.
What is Flow Control?The management of data flow between computers, devices, or network nodes is known as flow control. This allows the data to be processed at an effective rate. Data overflow, which occurs when a device receives too much data before it can handle it, results in data loss or retransmission.
A design concern at the data link layer is flow control. It is a method that typically monitors the correct data flow from sender to recipient. It is very important because it allows the transmitter to convey data or information at a very quick rate, which allows the receiver to receive it and process it.
The amount of data transmitted to the receiver side without any acknowledgement is dealt with by flow control.
Thus, option C is correct.
For more information about Flow Control, click here:
https://brainly.com/question/28271160
#SPJ5
Gray London is a retired race car driver who helped Dale Earnhardt, Jr. get his start. He is writing a book and making a video about the early days or Dale Earnhardt. He is trying to decide whether to market these items directly over the Internet or to use intermediaries. To make this decision, he needs to know the pros and cons of each route. Provide that information and make a recommendation to him.
Answer:
Explanation:
Marketing your product directly over the internet can lead to much greater profits and there are many options that you can choose from in order to target the correct audience. Unfortunately, doing so does require marketing knowledge and is basically like growing a business. If you were to use intermediaries they already have the knowledge necessary to market your product but will take a percentage of the profits, which will ultimately limit your gains. Since Gray London is a race car driver, I am assumming that he does not have any prior technological expertise or marketing expertise, therefore I would recommend using intermediaries.
Write a class Example() such that it has a method that gives the difference between the size of strings when the '-' (subtraction) symbol is used between the two objects of the class. Additionally, implement a method that returns True if object 1 is greater than object 2 and False otherwise when the (>) (greater than) symbol is used. For example: obj1
Answer:
Here the code is given as follows,
Explanation:
class Example:
def _init_(self, val):
self.val = val
def _gt_(self, other):
return self.val > other.val
def _sub_(self,other):
return abs(len(self.val) - len(other.val))
def main():
obj1 = Example('this is a string')
obj2 = Example('this is another one')
print(obj1 > obj2)
print(obj1 - obj2)
main()
Output:-
(a) Define a goal for software product quality and an associated metric for that attribute. (b) Explain how you could show that the goal is validatable. (c) Explain how you could show that the goal is verifiable. 2. (a) Create a list of software product attributes and a list for software project attributes. (b) Rank these in the order of how difficult you consider them to be measured. (c) Discuss the reasons for your choices
In the forward chaining technique, used by the inference engine component of an expert system, the _____ condition is evaluated first.
Answer:
"if" is the right response.
Explanation:
Forward chaining is being utilized just to split the logical sequential order down as well as operate throughout every component once the preceding one is accomplished, from start to finish.Its whole algorithm begins with proven information that activates all the rules, which are fulfilled as well as makes established realities even more complete.what its the difference between Arduinos and Assembler?
Answer:
The Arduino boards can be programmed in assembly. All you need is an ICSP Cable (In Circuit Serial Programmer) and the AVR toolchain (free from ATMEL) to write to the board. You then get the advantage of on board debugging.
As you suggested, you can just slap an ATMEL chip on a breadboard and go to town.
Explanation: cause i said so
Functions IN C LANGUAGE
Problem 1
Function floor may be used to round a number to a specific decimal place. The statement
y = floor( x * 10 + .5 ) / 10;
rounds x to the tenths position (the first position to the right of the decimal point). The
statement
y = floor( x * 100 + .5 ) / 100;
rounds x to the hundredths position (the second position to the right of the decimal
point).
Write a program that defines four functions to round a number x in various ways
a. roundToInteger( number )
b. roundToTenths( number )
c. roundToHundreths( number )
d. roundToThousandths( number )
For each value read, your program should print the original value, the number rounded to
the nearest integer, the number rounded to the nearest tenth, the number rounded to
the nearest hundredth, and the number rounded to the nearest thousandth.
Input Format
Input line contain a float number.
Output Format
Print the original value, the number rounded to the nearest integer, the number rounded
to the nearest tenth, the number rounded to the nearest hundredth, and the number
rounded to the nearest thousandth
Examples
Example 1
Input 1
24567.8
Output 1
24567.8 24568 24570 24600
Write an application that finds the smallest of several integers. Assume that the first value read specifies the number of values to input from the user. C
Answer:
Following are the code to the given question:
#include<stdio.h>//include header file
int main() //defining a main method
{
int a[100],k,x,s; //defining integer variable and an array
printf("Input the number of element want to insert array: "); //print message
scanf("%d",&x); //input value
printf("Enter array value: \n"); //print message
for(k = 0; k<x; k++) //defining a loop that inputs values
{
scanf("%d",&a[k]); //use array to input value
}
s = a[0]; //holding first array value in array
for(k=0;k<x;k++) //use for loop
{
if(a[k]<s) //use if block to check the smallest array value
{
s=a[k];//holding smallest array value
}
}
printf("smallest number= %d",s);//print smallest value
}
Output:
Please find the attached file.
Explanation:
In this code an array and another integer variable "a[100], i,n, and s" is is declared, in which the array and n for input the value from the user-end.
In the next step, an "s" variable is declared that inputs the first array element value in s and use a loop to check the smallest array element and prints its value.