Program using For loop:
#include <iostream>
#include <vector>
#include <iomanip> // std::setprecision
using namespace std;
int main()
{
//Declaring variables
double res;
//Declaring vector
vector<int> vec;
//This loop will populates the inches values into vector
for(int i=0;i<=24;i++)
{
vec.push_back(i);
}
//Setting the precision to 2 decimal places
std::cout << std::setprecision(2) <<
std::fixed;
//Displaying the inches and feet table
cout<<"Inches\t\tFeet"<<endl;
cout<<"--------------------"<<endl;
for(int i=0;i<vec.size();i++)
{
res=i*0.0833333;
cout<<i<<"\t\t"<<res<<endl;
}
return 0;
}
___________________
Program Using While loop:
#include <iostream>
#include <vector>
#include <iomanip> // std::setprecision
using namespace std;
int main()
{
//Declaring variables
double res;
//Declaring vector
vector<int> vec;
int i=0;
while(i<=24)
{
vec.push_back(i);
i++;
}
int len=vec.size();
//Setting the precision to 2 decimal
places
std::cout << std::setprecision(2) <<
std::fixed;
//Displaying the inches and feet table
cout<<"Inches\t\tFeet"<<endl;
cout<<"--------------------"<<endl;
i=0;
while(i<=len)
{
res=i*0.0833333;
cout<<i<<"\t\t"<<res<<endl;
i++;
}
return 0;
}
______________________
output:

___________Thank You
Use a for-loop to solve the following problems, and then repeat using a while-loop. Create a...
Using mat lab to do it
Create a single script file named yourname_While.m to answer the following problems. The file must be in cell mode to distinguish each problem. Make sure your script is nicely commented for each problem. Consider the following matrix of values: x =[345, 23, 17, 34, 85, 334, 111, 1067] Use a for loop and if statement to determine how many values greater than 30? Use fprintf to display the result. Repeat Problem 1., but use...
1. Create an PL/SQL anonymous block. Using a “while” loop, display on the console those rows where a quantity of shipments for a project are greater than the average quantity of shipments for that project. 2. Repeat using a FOR loop. // TABLE INFO : SHIPMENTS(SUPPLIERNO, PARTNO, PROJECTNO, QUANTITY, SHIPDATE, ARRIVEDATE)
Create function files that will use a “for” loop to perform the following tasks for a random input array “x”: (a) Count how many elements are greater than an arbitrary integer. Display these values as well as the count using “fprintf”. (b) Calculate the arithmetic mean of array “x” without using the built-in functions “sum”, “mean”, etc. and display the result using “fprintf”.
8. Use a for loop to create a table that converts inches to feet. Java Programming
Having trouble with the do while/while loop and the switch
statement. I got some of the switch statement but cant get the
program to repeat itself like it should.What i have so far for my
code is below. Any help is appreciated... i am not sure what I am
doing wrong or what i am missing. I am completely lost on the while
loop and where and how to use it in this scenario.
import java.util.Scanner;
public class sampleforchegg {...
In Javascript: While loop: use a while loop to calculate and display the Kelvin temperature values for each Fahrenheit temperature value range from 0 to 100 in increment of 10. use the formula tk = (tf -32) x 5/9 + 273.15 The values should be displayed exactly as shown: -17, -12, -6, -1, 4, 10, 15, 21, 26, 32, 37
write a java program that does the following Part one Use a For loop to compute the sum of all the odd numbers from 1 through 99. Your result should be labeled, and the value should be 2500. Print your name 7 times using a While loop. String dogNames[ ] = {"Sam","Buster","Fido","Patches","Gromit","Flicka"}; Using the array defined here, print the values of the array vertically and horizontally using one For-Each loop. Reverse the logic (Nested loops: Indent text) so that the...
Create a while loop that will execute the following code 12 times using a counter that starts at 1 and is incremented by 1 each time through the loop. Within the while loop, create a switch statement that will print out the number of days in each of the months of the year. - Use fall through capabilities so that you only have one print statement for all of the months that contain 31 days. Do not worry about leap...
Using R, solve these problems:
1)
2)
3)
Exercises • Create a vector grades=c(88,90,70,50) • Add names to the vector: Jon Snow, Tyrion, Arya, Cersei • Delete Cersei grade • Change Arya grade to 85 Exercises • Create the following vector [roquefort, ham, chicken liver, beef tongue, beef heart, mozzarella, watermelon] • Create a logical vector: True if you like the food, False otherwise. • Use the logical vector to select the food you like. • Create a new vector...
Create a function without using import scanner and you must create and use a java method in this assignment | x+2 x<= 2 f(x) = | | -x^2 +2x +2 x>2 Name the function f Ask the user to enter a double, calculate and display the resulting value of f(x) +5 pts: loop the ask-and-calculate-and-display loop Your main program should: Get a number (x) Use f to calculate a value of the function Display the result (optional) loop back and...