1answer.
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
lilavasa [31]
3 years ago
6

What's the code?

Computers and Technology
1 answer:
lys-0071 [83]3 years ago
3 0

Answer:

Explanation:

#include <iostream>

using namespace std;

// Recipe of single portion salad

int main()

{

   float Qing[3]={0.0,0.0,0.0};

   string ItemName[3]={" "," "," "};

   int qty=0;

   cout<<"Please enter 3 Ingredients required for Salad and Quantity required for a single serve"<<endl;

   for (int i=0;i<3;i++)

   {

       cout<<"Enter the ingredient number "<<(i+1)<<" :";

       cin>>ItemName[i];

       cout<<"Qty required for single serve (in Oz) :";

       cin>>Qing[i];

   }

   cout<<"Number of servings required :";

   cin>>qty;

   cout<<endl<<"Total Quantities required for "<<qty<<" servings"<<endl;

   for (int i=0;i<3;i++)

   {

       cout<<ItemName[i]<<" Qty for "<<qty<<" servings :"<<(Qing[i]*qty)<<" Oz."<<endl;

   }

   return 0;

}

// You can run this after compiling without any problem.

You might be interested in
Q1). Write a python program to pass a list to a function and double the odd values and half even values of a list and display li
zepelin [54]

Answer:

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - Python.

def f(x):

   new_list=[]

   for i in x:

       if i%2==0:

           new_list.append(i//2)

       else:

           new_list.append(i*2)

   return new_list

   

my_list=list(range(1,6))

print('Original List:',my_list)

my_list=f(my_list)

print('Modified List:',my_list)

\textsf{\large{\underline{Logic}:}}

  1. Create a new list.
  2. Iterate over the list passed into the function.
  3. Check if the element is even or not. If true, append half the value of element in the list.
  4. If false, append twice the value of the element in the list.
  5. At last, return the new list.

There is another way of doing this - By using map() function.

—————————————————————————————

def f(x):

   return list(map(lambda x:x//2 if x%2==0 else 2*x,x))

   

my_list=list(range(1,6))

print('Original List:',my_list)

my_list=f(2my_list)

print('Modified List:',my_list)

—————————————————————————————

\textsf{\large{\underline{O{u}tput}:}}

Original List: [1, 2, 3, 4, 5]

Modified List: [2, 1, 6, 2, 10]

8 0
2 years ago
How do I turn of the noise canceling feature on my beats studio wireless?
zysi [14]
You press and hold the "b" button on your left earmuff, but you have to hold it down as long as you want ANC (Automatic Noise Cancelling) to be turned off, in other words, as soon as you release the button, ANC will be turned back on. Unfortunately, this will also mute your music. 
5 0
3 years ago
30% of the mass of an objects is 24 kilograms. use this fact to find:
Triss [41]

Answer:

chemați. mfvd5. fn. cfcfcfcfcfcfcf 4t

6 0
2 years ago
Suppose you are provided with 2 strings to your program. Your task is to join the strings together so you get a single string wi
Mariulka [41]

Answer:

public class TestImport{

   public static void main(String[] args) {

       String string1 = args[1];

       String string2 = args[2];

       System.out.println(string1 +" " +string2);

   }

}

Explanation:

The solution here is to use string concatenation as has been used in this statement System.out.println(string1 +" " +string2);

When this code is run from the command line and passed atleast three command line arguments for index 0,1,2 respectively, the print statment will return the second string (that is index1) and the third argument(that is index2) with a space in-between the two string.

6 0
2 years ago
Write a Python program that takes a file name as input and generates the following output: File size in bytes and KBs Time the f
Airida [17]

Answer:

See explaination

Explanation:

import os

import time

from stat import *

file = input("Enter file name: ")

details = os.stat(file)#stores statistics about a file in a directory

print("File size: ", details[ST_SIZE])#retreiving size

print("File last accessed time: ", time.asctime(time.localtime(details[ST_ATIME])))#access time

print("File last modified time: ", time.asctime(time.localtime(details[ST_MTIME])))#modified time

print("File creation time: ", time.asctime(time.localtime(details[ST_CTIME])))#creation time

print("First character: ", file[0])

print("Middle character: ", file[len(file) // 2])

print("Last character: ", file[len(file) - 1])

num_words = 0

num_lines = 0

f=open(file, "r")

lines = f.readlines()

for line in lines:

num_lines = num_lines + 1

num_words = num_words + len(line.split())#add no. of words in that line

print("Number of lines: ", num_lines)

print("Number of words: ", num_words)

8 0
2 years ago
Other questions:
  • DSL technology is less efficient for service providers in the United States because many of their customers live in less-densely
    11·1 answer
  • Write the function mystrchr(). the function has two parameters: a const char * s pointing to the first character in a c-style st
    14·1 answer
  • Which is a false statement considering copyright law?
    13·2 answers
  • What can a scientist do if he repeats and experiment and gets diffrent results?
    5·1 answer
  • A chemistry teacher colleague of yours uses video regularly in their courses, but commented to you about how much time it takes
    15·2 answers
  • The results of the SPEC CPU2006 bzip2 benchmark running on an AMD Barcelona has an instruction count of 2.389E12, an execution t
    6·1 answer
  • 8. A sprite is a simple spider shaped thing with n legs coming out from a center point. The angle
    10·1 answer
  • What are the concerns surrounding 5G cellular networks?​
    6·1 answer
  • Write pseudocode for washing a car using at least five steps.
    13·1 answer
  • To use the replace feature we can simply just press Carl+h,Carl+c,Carl+r
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!