answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mariulka [41]
2 years ago
3

Struct and Direct Field Indexing Write a function called ConvertToDecadesAndYears to convert totalYears to decades and years. Th

e decades and years should be returned using a struct that has two fields, decades for the number of decades, and years for the number of years.

Computers and Technology
1 answer:
den301095 [7]2 years ago
3 0

Answer:

Please refer to the attached image for the solution code.

Explanation:

To return a struct data type from a function, we need to define the struct data in advance (Line 1 - 4). As required by the question, the <em>struct </em>duration consists of two members, <em>decade</em> & <em>year</em>.

Next we can proceed to define the function <em>ConvertToDecadesAndYears() </em>that take one input parameter, <em>totalYear </em>(Line 6). Please note the function is also defined with a return data type,<em> struct duration.</em>

<em />

Next, we calculate the year, <em>y,</em>  by calculating modulus (remainder) of <em>totalYear </em>when divide it by 10 (Line 9) and calculate the decade, <em>d</em>,  by using floor function to round down the division result of<em> totalYear </em>by 10.

We can then assign the y & d to the member of the struct data, d1, (Line 12 & 13) and return it as output (Line 15).

You might be interested in
This question involves the creation of user names for an online system. A user name is created based on a user’s first and last
Evgen [1.6K]

Answer:

See explaination

Explanation:

import java.util.*;

class UserName{

ArrayList<String> possibleNames;

UserName(String firstName, String lastName){

if(this.isValidName(firstName) && this.isValidName(lastName)){

possibleNames = new ArrayList<String>();

for(int i=1;i<firstName.length()+1;i++){

possibleNames.add(lastName+firstName.substring(0,i));

}

}else{

System.out.println("firstName and lastName must contain letters only.");

}

}

public boolean isUsed(String name, String[] arr){

for(int i=0;i<arr.length;i++){

if(name.equals(arr[i]))

return true;

}

return false;

}

public void setAvailableUserNames(String[] usedNames){

String[] names = new String[this.possibleNames.size()];

names = this.possibleNames.toArray(names);

for(int i=0;i<usedNames.length;i++){

if(isUsed(usedNames[i],names)){

int index = this.possibleNames.indexOf(usedNames[i]);

this.possibleNames.remove(index);

names = new String[this.possibleNames.size()];

names = this.possibleNames.toArray(names);

}

}

}

public boolean isValidName(String str){

if(str.length()==0) return false;

for(int i=0;i<str.length();i++){

if(str.charAt(i)<'a'||str.charAt(i)>'z' && (str.charAt(i)<'A' || str.charAt(i)>'Z'))

return false;

}

return true;

}

public static void main(String[] args) {

UserName person1 = new UserName("john","smith");

System.out.println(person1.possibleNames);

String[] used = {"harta","hartm","harty"};

UserName person2 = new UserName("mary","hart");

System.out.println("possibleNames before removing: "+person2.possibleNames);

person2.setAvailableUserNames(used);

System.out.println("possibleNames after removing: "+person2.possibleNames);

}

}

8 0
2 years ago
A slide in Blake's presentation contained the following information:
deff fn [24]

Answer:

consistent phrasing is missing

Explanation:

If you will note carefully, the bullets are not in correct format. The model is missing. The correct one is as below.

Risks

The correct form of presentation is as below:

1. Risks

a. employees  

              a. physical illness

              b. mental illness

              c. death  

2. Customers  

              a.   complaints

              b.   downtime

3.  Benefits

However, the content seems to be complete now, and hence not anything else is required. And since its not something very tough to decide to go with, bite the bullet is certainly not an issue.  

3 0
2 years ago
B. Write a function that takes one double parameter, and returns a char. The parameter represents a grade, and the char represen
9966 [12]

Answer:

#include <iostream>

#include <cstdlib>

using namespace std;

char grade(double marks){

   if(marks>=90)

   {

       return 'A';

   }

   else if (marks >=80 && marks<90)

   {

       return 'B';

   }

   

   else if (marks >=70 && marks<80)

   {

       return 'C';

   }

   

   else if (marks >=60 && marks<70)

   {

       return 'D';

   }

     else if ( marks<60)

   {

       return 'F';

   }

}

int main()

{

   double marks;

cout <<"Ener marks";

cin >>marks;

char grd=grade(marks);

cout<<"Grae is "<<grd;

return 0;

}

Explanation:

Take input from user for grades in double type variable. Write function grade that takes a parameter of type double as input. Inside grade function write if statements defining ranges for the grades. Which if statement s true for given marks it returns grade value.

In main declare a variable grd and store function returned value in it.

3 0
2 years ago
I need help asap please :) I will mark brainliest for whoever gets the right answer! x
Nina [5.8K]

1.) Average

2.) Ascending

Using this would give an average score for each team, when using the Average function, you use scores from many different games to not be biased, and it gives an accurate description of the teams scores and it's a fair way to find where they stand in respect tot he other team.

4 0
2 years ago
Form the recurrence relations (RRs) for the number of vertices and the number of edges of a hypercube of n dimensions, Hn. Solve
Rus_ich [418]
I'll write it below Step-by-step explanation: Q1 a side that has 10 sides and 10 angles is called decagon. Q2 it is nonagon Q3 it is Pentagon Q4it is heptagon
8 0
2 years ago
Other questions:
  • You have been tracking your exercise routine, which involves running, lifting weights, yoga, and stretching. You want to see wha
    15·2 answers
  • Emma wants to create a website that will contain mostly textual information pertaining to book reports she has to create. Which
    14·2 answers
  • Jennifer has written a short story for children. What should be her last step before she submits the story for publication?
    11·1 answer
  • How can a signature be added to an email message? Check all that apply.
    10·2 answers
  • In this exercise we look at memory locality properties of matrix computation. Th e following code is written in C, where element
    9·1 answer
  • Write a split check function that returns the amount that each diner must pay to cover the cost of the meal The function has 4 p
    14·1 answer
  • __________ is the current federal information processing the standard that specifies a cryptographic algorithm used within the U
    12·1 answer
  • ___refers to self-acting or self-operating.
    11·1 answer
  • In this problem, you will derive the efficiency of a CSMA/CD-like multiple access protocol. In this protocol, time is slotted an
    14·1 answer
  • Write a class named Employee that has private data members for an employee's name, ID_number, salary, and email_address. It shou
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!