Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91560937
user_interface.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 12, 05:41
Size
2 KB
Mime Type
text/x-c
Expires
Thu, Nov 14, 05:41 (2 d)
Engine
blob
Format
Raw Data
Handle
22283412
Attached To
R9490 Homework_sp4e_Peruzzo_SáezUribe
user_interface.cpp
View Options
//
// Homework 2
// 2019
// CP & AASU
//
#include "user_interface.h"
#include <iostream>
bool
ask_type_of_serie
(
user_choices
&
mychoices
)
{
std
::
cout
<<
"
\n
"
<<
"Choose what to use: "
<<
"
\n
"
;
std
::
cout
<<
"'1' for ComputeArithmetic "
<<
"
\n
"
;
std
::
cout
<<
"'2' for ComputePI "
<<
"
\n
"
;
std
::
cout
<<
"'3' for EXIT the program "
<<
"
\n
"
;
std
::
cin
>>
mychoices
.
type_of_serie
;
return
!
(
mychoices
.
type_of_serie
!=
1
and
mychoices
.
type_of_serie
!=
2
and
mychoices
.
type_of_serie
!=
3
);
}
void
ask_N
(
user_choices
&
mychoices
)
{
std
::
cout
<<
"
\n
"
<<
"Input N (integer) "
<<
"
\n
"
;
std
::
cout
<<
"N = "
<<
"
\n
"
;
std
::
cin
>>
mychoices
.
N
;
}
void
ask_frequency
(
user_choices
&
mychoices
)
{
std
::
cout
<<
"
\n
"
<<
"Input frequency (integer) "
<<
"
\n
"
;
std
::
cout
<<
"frequency = "
<<
"
\n
"
;
std
::
cin
>>
mychoices
.
frequency
;
}
void
ask_precision
(
user_choices
&
mychoices
)
{
std
::
cout
<<
"
\n
"
<<
"Input the precision for the results (integer) "
<<
"
\n
"
;
std
::
cout
<<
"precision = (default -> 10 decimals) "
<<
"
\n
"
;
std
::
cin
>>
mychoices
.
precision
;
}
bool
ask_extension_type
(
user_choices
&
mychoices
)
{
bool
if_the_guy_chosed
=
false
;
while
(
!
if_the_guy_chosed
)
{
std
::
cout
<<
"
\n
"
<<
"Choose extension type for writing the results: "
<<
"
\n
"
;
std
::
cout
<<
"'1' .txt and
\"
\"
between numbers"
<<
"
\n
"
;
std
::
cout
<<
"'2' .csv and
\"
,
\"
between numbers"
<<
"
\n
"
;
std
::
cout
<<
"'3' .psv and
\"
|
\"
between numbers"
<<
"
\n
"
;
std
::
cout
<<
" default value: 1 "
<<
"
\n
"
;
std
::
cin
>>
mychoices
.
extension_type
;
if_the_guy_chosed
=
(
mychoices
.
extension_type
==
1
or
mychoices
.
extension_type
==
2
or
mychoices
.
extension_type
==
3
);
}
return
true
;
}
bool
ask_write_or_print
(
user_choices
&
mychoices
)
{
bool
if_the_guy_chosed
=
false
;
while
(
!
if_the_guy_chosed
)
{
std
::
cout
<<
"
\n
"
<<
"Choose: "
<<
"
\n
"
;
std
::
cout
<<
"'1' to write the results on a file"
<<
"
\n
"
;
std
::
cout
<<
"'2' to print the results on the screen"
<<
"
\n
"
;
std
::
cin
>>
mychoices
.
write_or_print
;
if_the_guy_chosed
=
(
mychoices
.
write_or_print
==
1
or
mychoices
.
write_or_print
==
2
);
}
return
true
;
}
Event Timeline
Log In to Comment